interface-oriented benefits

Source: Internet
Author: User
An interface can be examined from three aspects:
The creator (or the facilitator), the implementing person (or the producer), the caller (or the consumer).

An interface is essentially a relationship between the creator and the caller by the creator.

So the usual "interface-oriented programming" can be understood as:
Only the implementation and the caller follow the guideline of "interface-oriented programming", and the coordination purpose of the formulation can be achieved.

A cliché example is JDBC.

A lot of people don't understand: since I have to deploy a driver in advance for every connection to a database (such as MySQL), I can't just access the driver. What more do you want JDBC?

In fact, JDBC has played a crucial role: Because the driver is written in a way that JDBC requires, you can use it in a JDBC way.
In other words, if the driver provider does not write according to the JDBC Standard, but writes it in its own original way, then you need to take the time to look at the driver's documentation to find out the usage when using the driver. And when you later decide to use another database, the driver for this database is not written in JDBC, you have to figure out another completely different usage, and all your code must be changed accordingly. This price is unthinkable.

The situation now is that driver providers are written in the way that JDBC prescribes, and programmers use them in the way that JDBC prescribes. Programmers don't have to worry about which database they're using, and driver writers don't have to bother writing interface documents to explain the driver's usage to programmers.

Now, do you think the benefits of interface-oriented programming are not obvious?

When you are typing on your keyboard, do you think that the type of typing you learned at school is still in use, because all the keyboard layouts are the same.
At this point, you will not be sincerely grateful to the design of the keyboard layout of the people. It is he who lets you just learn a typing method that can be used on all computer keyboards.

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.