In UML, we know the object-oriented, so we have a preliminary understanding of object-oriented, and lay a good foundation for understanding object-oriented in the future.
Abstract, encapsulation, inheritance and polymorphism, this is the four basic features of object-oriented technology, and is also the composition of object-oriented programming thought. It is these characteristics, so that the security, reliability and reusability of the program are ensured, and after development, the application of object-oriented ideas more extensive, not only software, in hardware, artificial intelligence, distributed computing, operating systems and other fields of application is also more and more important.
Abstract
Abstraction ignores the non-essential characteristics of things that are irrelevant to the current goal, and emphasizes the characteristics associated with the current goal. For example, a globe, our goal is to know the whole Earth through a globe, regardless of the proportion of parts of the globe to the Earth's counterpart. This is just a model of the Earth, the simpler the abstract model, the less the feature, the more common the model. By observing the globe, we can find the four oceans, which are recognized on seven continents, and do not necessarily know the exact appearance of every continent or ocean, which is found on a globe, and can be distinguished by a casual look.
Abstract can also classify the information, the object according to a certain standard division, to achieve the hierarchical structure of the abstract model, more general and easy to deal with. In this way, the abstract class provides a guarantee for the reuse of objects.
Packaging
The mechanism by which the State and behavior of an object are tied together, so that the object forms an independent whole, and hides the inner details of the object as much as possible. The information shielding effect of encapsulation reflects the relative independence of things and helps to protect the integrity of the data. The binding has two meanings: the whole state and behavior of the object are combined together to form an indivisible whole. The object's private properties can only be modified and read by the object's behavior, and the inner details of the object should be concealed as far as possible, and the external interface can only be implemented by the outside interfaces. The result of encapsulation is that parts outside the object cannot arbitrarily change the internal properties or state of an object, and can be controlled by a public access controller to control the properties or state changes encapsulated by the object.
In object-oriented program design, it is not possible to blindly restrict the object's properties from being read directly externally, otherwise it will add a lot of useless operations, to analyze the properties of the object and then set.
Inherited
All kinds of things not only have their generality, there are various things of their own characteristics, if the characteristics of the things ignored, then the world will become a layer unchanged, lost the wonderful world of characteristics. The characteristics and individuality of the things are the solid reasons of the world at this level, which are also the parts that distinguish the common things and complement each other.
In contrast to abstraction, abstraction is the abandonment of attributes between things, the abstraction of commonalities between things into a class, and inheritance is the extraction of multiple classes of different characteristics of things, which has all the characteristics of the previous class, a subset of the previous class, and a hierarchical structure. Thus, it can be seen that inheritance and abstraction are two inverse processes, abstraction is a common class abstracted from multiple objects, is a process from many to few, and inheritance is a process that is layered from the object class into multiple subclasses with its own characteristics, which is a small to many.
In particular, inheritance means "auto-owning", that is, in a special class, there is no need to re-define the defined properties and behaviors in a generic class, but the special classes are automatically, implicitly owning the properties and behaviors of their generic classes, and these properties and behaviors are self-existent after inheritance. A generic class is called a base class, and a special class is called a derived class. For example, primary and secondary students, college students, graduate students these four special classes are the subclass of the general class of student class, and also the new class inherited from the student class, they automatically have all the properties and methods belonging to the student class, and at the same time they have their own characteristics, no longer redefine the properties and methods defined in the student class. The student class is the base class, the elementary school class is the derivation class.
Inheritance in the development of object-oriented software has the following purposes, or can be said to be advantageous: 1. The description of the class is more concise; 2. Ability to reuse and extend existing class library resources; 3. Software is easy to maintain and modify.
Polymorphic
Polymorphism refers to two or more objects that belong to different classes, and the ability to make different responses to the same message or method invocation. In object-oriented programming, polymorphism means that two or more of the same function names that belong to different classes correspond to multiple different functions with similar functions, and you can call these functions with the same name with different functions using the same invocation method. This can be understood, in a graph of the base class is a method of drawing, derived class rectangle and derived class Ellipse also has a method of drawing, but through the same drawing action, the rectangle class drawing is a rectangle, the ellipse is drawn out of the ellipse.
The combination of inheritance and polymorphism realizes the individualized design of software. Object- oriented abstraction and inheritance are more important, the object-oriented understanding is very helpful, when the object-oriented unfamiliar when you can take these two as a breakthrough point, a comprehensive understanding of object-oriented.
Object-oriented features