ArticleDirectory
- Encapsulation-hide internal implementation
- Inheritance-reuse object attributes and Behaviors
- Polymorphism-extends subclass Behavior
Object-oriented is of great significance, not just the use of object-oriented in programming.Programming Language(Oopl) implements object-oriented. Because everyone isProgramTo a large extent, it is considered that object-oriented programming is object-oriented. The misunderstanding here should be a misunderstanding that everyone may make when I first study programming. In fact, object-oriented is an idea. We need to use this idea throughout the entire process of software development to guide the process of analysis, design, and implementation.
There are three mechanisms to implement object-oriented programming languages. This article mainly explains why these implementation mechanisms are available in object-oriented programming languages, not just how these mechanisms are implemented in programming languages.
Encapsulation-hide internal implementation
After an object is instantiated, some changes may occur inside the object instance during the running process of the object instance, or the status of the object instance is changed externally, then, the caller of the object instance needs a mechanism to obtain the status of the object instance, and finally outputs the status to the customer.
Object instances use a large numberCodeDetermine the object type and object status, and then determine how to give the customer a response. The caller of the object instance needs to know the internal structure of the object instance. This mechanism is not in line with the real world, because we do not know the internal structure of another thing. For example, we don't know how the TV works. So what kind of mechanism should be determined to call the object instance to obtain the object's behavior? Generally, it is based on the Interface call contract (not the interface of the programming language ). The encapsulation method in oopl is used to hide the internal implementation.
Inheritance-reuse object attributes and Behaviors
Polymorphism-extends subclass Behavior