Ever since I did hello world with python, I've been using object-oriented programming and the concept of classes. I want to understand it soon (complete understanding) and I will summarize it in my own way.
There are too many horizontal terms such as objects, classes, instances, methods, overrides, intelligence, etc.! I remember the world history I did when I was in junior high school, like the Five Good Emperors ... (laughs)
Upon examination, it seems that objects and imperatives are paired concepts.
Imperative programming: Data and instructions are described and processed separately. ** Object-oriented: The idea of combining data and instructions, the idea of grouping variables and functions **
It seems to be an object-oriented outline to think about combining data and instructions that were processed separately. In addition, the "instruction" referred to here is called a "method".
** Differences between classes and functions ** are also considered to be in this respect.
You can see that object-oriented refers to thinking. That idea can be realized by using "classes". Classes are often compared to blueprints.
I think you can think of putting things called "data" and "instructions (methods)" in a box called a class.
I found the idea of data and methods easy to understand on this site.
It's a familiar word for "creating an instance". An instance is an example, an example, an example, which is "generated" when you actually use a class.
If the class is a blueprint for a car, then the instance can be thought of as a more specific "Benz" or "Ferrari" blueprint. The class has an image that contains the instance, but is it correct ...?
I wonder if an instance will be a data framework (name, weight, etc.) defined in the class with specific numbers.
Parent class to superclass Child classes are called subclasses
Creating a subclass using a superclass as a template is called inheritance. Subclasses can take advantage of superclass data and methods, as well as add other methods to extend their functionality. Also, rewriting a superclass method and overwriting it is called overriding.
Inheriting from multiple superclasses is called multiple inheritance.
Recommended Posts