Who owns the interface?

Source: Internet
Author: User

This article from http://www.cnblogs.com/goodcandle/archive/2005/11/07/ownapi.html

 

In my Article Home Finance Manager--Software Design There are two classes : Cmodelbase And Cffmmodel , Cffmmodel Yes Cmodelbase . At the time of design, I thought it was quite good. The two should have some connection. From the perspective of name, I can see it at first glance. Cmodelbase Yes Cffmmodel The name of the parent class. But is this really good?

There is a saying: "An interface belongs to its customers, rather than its derivation ." When I read this passage, I felt quite touched. The logical binding relationship between a customer and an interface is stronger than that between an interface and its derivation. We often say that "customers are God. In fact, when designing the software, we must take it into consideration. If your interface is easy to misunderstand or the interface is too complex, then the user (that is, the so-called customer) I am not willing to use it. Although the customer may not be clear here, because the caller may be your colleague, but if you call your interface, it is the customer, you have to take responsibility for him.

Here is an example:

Here, if the interface class is namedClightinterfaceThe customer thinks this class can only processClightBut in factClightinterfaceCan process all objects with switch operations.

So I'm writing a Home Finance ManagerCodeYou don't have to hesitateCmodelbaseChangeCviewoperate, Possibly in myProgramBut the habit needs to be developed slowly.

The keep in mind interface belongs to the customer.

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.