Interfaces and Classes

Source: Internet
Author: User

Summary Interfaces and classes represent the development direction of object-oriented methodology. The concept of class appears in the early stage of object-oriented, which represents a specific thing or a certain type of thing in reality. Interfaces appear later than classes, represents the characteristics of reality or a certain type of things. It is abstract. There is always a Primary and Secondary Division of things, and the object-oriented methodology is no exception. This article puts forward the design point of the primary interface and the secondary class. Keywords Design, interface, class, combination, inheritance Directory 1.Overview 2.Class and interface development 3.Divide things based on interfaces 4."Class "weakened, the interface becomes more Connotation 5.Interface-oriented instead of class-Oriented Programming 6.The essence of interfaces lies in abstraction. 1.Overview Interfaces and classes represent the development direction of object-oriented methodology. The concept of class appears in the early stage of object-oriented, which represents a specific thing or a certain type of thing in reality. Interfaces appear later than classes, represents the characteristics of reality or a certain type of things. It is abstract. In the object-oriented vocabulary, there is also a very important concept, that is, the abstract class, which can be seen as a combination of interfaces and classes, which reflects the balance between ideal and reality. (Note: The classes mentioned in this Article do not include abstract classes ). 2.Class and interface development After so many years of development, object-oriented programming has evolved from Class-oriented programming to component-oriented programming to service-oriented programming. In fact, it is easy to see that the concept of classes is gradually weakened. The connotation of interfaces is constantly enriched. Object-oriented classes are often used to represent actual and perceptible things, representing a non-abstract and specific concept. An interface is an abstract concept. What actually exists is often a representation that people can perceive and constantly change. The abstraction of an interface determines that it is basically stable. Its value lies in that it reflects the future development direction of a class of things and does not deviate from the essence of things. Whether in the process-oriented, object-oriented, or service-oriented era. We can see the connotation and charm of the abstract interface. In the process-oriented era, interfaces represent the ability of a system to open to the outside. In the age of object-oriented, interfaces represent the characteristics of a class. In the age of component orientation, interfaces represent the features of a component. In the service-oriented era, interfaces represent contracts between two homogeneous or heterogeneous systems. 3.Divide things based on interfaces An interface represents one or more features of a thing. Different things may have the same characteristics, such as humans and animals. Some features are the only feature of a certain type of things. Therefore, we can use interfaces to differentiate things of different classes. Therefore, things can be completely classified through interfaces. If we try to divide different things through classes, we will find that their expressiveness is very weak. Because a class represents a special thing to a large extent, it is often not universal. Even classes that are initially considered universal will gradually become special with the corruption of the system. This can be avoided by using interfaces. Because it is born with abstraction, it represents the essence of things. The essence of things is basically stable and will not change. Therefore, we should divide things according to interfaces rather than classes. 4."Class" is weakened, and interfaces become richer There is no concept of class in the process-oriented era. The system is composed of a series of processes and data, and there is no such concept as encapsulation. In the early days of the object-oriented era, because of the need for encapsulation changes, classes almost become synonymous with object-oriented. In the age of component-oriented, the role of classes began to be weakened, and components were no longer considered a collection of classes, instead, it is a collection of interfaces. components can be implemented using different technologies, and interfaces represent the capabilities of this component. In the service-oriented era, coarse-grained services have almost no shadows of classes in the past, although it still represents one or more types of things (systems), those features of the class have been replaced by autonomy and contracts, and interfaces float above the class in the form of contracts. 5.Interface-oriented instead of class-Oriented Programming Interfaces and classes are considered the same concept in many languages. This also induces people to regard classes as interfaces. As a result, the system becomes bloated, stiff, and unmaintainable. The key point is that in a system, classes often represent special concepts. In the ever-changing needs, classes become more and more special and finally "four nos ", as a result, the system is corrupted. Therefore, class-oriented programming is not a good action. Interfaces represent a class of abstract concepts. In well-designed systems, interfaces often have sufficient abstract meaning and are stable enough. When the demand changes, the features represented by an interface can be basically unchanged. New features can be expanded in various abstract ways. This not only enhances the design elasticity and reusability, but also reflects the need for harmony and unification for the development of things. 6.The essence of interfaces lies in abstraction. The charm of abstraction is that it makes a seemingly complex system as harmonious and unified as everyday life. The interface is the product of abstraction. It represents the abstraction of the nature of things and is basically stable in a certain period of time. Therefore, the essence of interfaces lies in abstraction.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.