Personal understanding of the interface interface

Source: Internet
Author: User

What does it mean to say that "class is an abstraction of an object, the interface is drawn more sharply, is the abstraction of a class "? That is, the class includes many other objects, which are a collection of objects that are the properties or methods of the class, while the interface includes many classes, but he differs from the class. Imagine if the "interface" is to put the class into the "interface", then the so-called "interface" is actually a class. So the interface is not to put the class into the internal, then we have to understand the meaning of "interface", the interface in reality is the meaning of the socket , and the socket is two sides , one side is to plug the jack, the other side is to the circuit . No matter how complicated the circuit is, the jack is the shape, or the double hole, or the three holes. Then all the two-hole circuit is not able to have the same socket , different classes correspond to different circuits, Jack is the interface method, so that the interface and the relationship between the class is ready: All the same method of the class, it can constitute the same interface;

To cite another example, there is now an organization called WCG, which deals with the economy between countries, and the administrative personnel give the organization the names of the relevant laws without writing specific provisions. Suddenly one day do not know how the United States bothered, joined the organization, after the United Kingdom, France and Germany found the eldest brother added, they want to add, add more and more countries. After that, various countries have different laws because of regional, cultural and economic differences. But their same type of law is called a name, for example, about the economy is called economic law; one day China wants to do business with some of its members, and China needs to understand the specific economic laws of its members. But our practice is very busy every day, there is no time to study the laws of each country. What about that? Xi has come up with a way: I decided to do business with the country, to see people's Law is not OK, anyway they are WCG, the law is the same name.

In this example: WCG is the interface, the law of the WTO is the Declaration of some methods of the interface, the specific country in the WTO is to implement the interface of the class, it is necessary to implement the interface method in the class; China corresponds to the class that will actually call the method in the WTO (note that the invocation, not the definition), That is, the class must contain a method that takes an interface as an argument, and this method passes through the object of the class that implements the interface during the invocation.

The above is temporarily my understanding of the interface, because the contact is not a lot of examples, there may be a partial suspicion, but the general meaning is this!

(the names in the examples are all nonsense, if they are identical, they are coincidental)

(reproduced please indicate the source, thank you)

Personal understanding of the interface interface

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.