Object-oriented and object-based differences are polymorphic, unrelated to inheritance.
Based on the object only supports the function of the abstract data type, inheritance also embodies a kind of is-a relation, also is abstract data type, just establishes a hierarchy system. But what is object-oriented? Is that depending on the actual type of object, different behaviors can be done automatically, but only in a consistent invocation form. In other words, it is the polymorphism of the virtual function implementation. The above view, in OO design has been recognized, another way to achieve polymorphism is generic.
"Object-oriented" and "Object-based" two different concepts. The three main features of object-oriented (encapsulation, inheritance, polymorphism) are not, usually "object-based" use the object, but can not take advantage of the existing object template to produce a new object type, and then produce a new object, that is, "based on the object" does not inherit the characteristics, and "polymorphic" is represented as a subclass of the parent class Without the concept of inheritance, it is impossible to talk about polymorphism. Many of today's popular techniques are object-based, using some encapsulated objects, invoking the object's methods, and setting the properties of the object. However, they do not allow programmers to derive new object types. They can only use methods and properties of existing objects. So when you decide whether a new technology is object-oriented, you can usually use the latter two features to judge. "Object-oriented" and "Object-based" implement the concept of "encapsulation", but the object-oriented implementation of "Inheritance and polymorphism", and "object-based" does not implement these, it is very mouth-opening.
People who are engaged in object-oriented programming can be divided into "creators of class Libraries" and "users of class libraries" according to the division of labor. People who use class libraries are not all people with object-oriented thinking, often know how to inherit and derive new objects to use the class library, but our thinking does not really turn around, the use of the class library is only in the form of object-oriented, but essentially just an extension of library functions. Object-oriented is an idea, a way of thinking about things, usually whether we solve the problem in a procedural way, or abstract it into an object to solve it. In many cases, we will unconsciously follow the process to solve it, rather than consider to solve the problem of abstraction as an object to solve it.
Object-oriented has several characteristics, encapsulation, inheritance, polymorphism. You cannot inherit without encapsulation, and there is no runtime polymorphism without inheritance. Object-based is not a separate theory, but an object-oriented primary stage, which is only encapsulation. It can only be called by putting properties, methods into the class, and instantiating the object. Learning object-oriented to start with the basic knowledge, learn to define the definition of class, interface, inheritance. Then we should study the real thing in detail, abstract the real thing or the noun in the requirement document to generate the class or attribute, and if it is the subject, it is most likely to define the class structure according to the whole sentence description generation method. It is called abstraction because it is necessary to ignore other things that the system does not need when defining a class member. Slowly you will find that the original program to keep adding and deleting code and refactoring. Experienced, you can design only add code, do not modify, delete the code of the class structure.
turn from [email protected]
About object-oriented and object-based