The colon and his students (serial 27)--Interface Services

Source: Internet
Author: User

27. Interface Services

Self-discipline should be strict, treat people should be wide--"Hong Chongming vegetable root Tan"

Exclamation point introspection: "We used to do OOP programming, always focused on how to use other classes to solve problems, but less consideration of the design of their own classes on the impact of other classes." ”

Quotes Open Previous notes: "As mentioned before, the OOP world is democratic, all objects are independent and equal citizens, have the right to seek services, also have the obligation to provide services." It seems that we have forgotten our obligations in the light of our rights. ”

The colon then proposes: "As a provider of services, the most important thing is to speak good faith." First of all, the service must be reliable, not responded-that is, the interface must fulfill its commitment, secondly, the service should be stable, can not be changed--that is, the interface once open, not arbitrarily change. ”

Full stop immediately understand: "From an abstract point of view, the reliability of services to ensure that the norms of abstraction, the stability of services to ensure that the data abstraction." ”

"Costing too! "Colon, Hi-chan," in contrast, the former is more important, but unfortunately, only the latter has legal protection-if the interface is discarded or its signature changes, will certainly implicate customers, at least through the compiler to find and modify, and the specification is only a semantic contract, without grammatical constraints, Not within the scope of the compiler's supervision. ”

Quote interrupt: "The compiler is out of the box, that's only a unit test." ”

"This is the primary purpose of unit testing. "The colon is very agreeable," in addition, the quality of the service has to be pure and complete. Unix has a philosophy: ' A program can do only one thing, but do it well '. Used in OOP, it is: ' A class only provides a set of services, but is perfect '. For example, the same mobile phone, old-style mobile phone service is pure, the modern smartphone is not-in addition to the phone, but also video, listen to music, play games, internet and so on, is entirely a combination of mobile phone and handheld computer. Another example, the same as communication tools, mobile phone services are complete, and the service provided by the BP machine is incomplete-can only receive information, can not send information. ”

Exclamation bobbing: "The provision of services is not pure, too little is not complete." So the design of the class is to achieve ' increase one point is fat, minus one point is thin ' beauty standard ah? ”

"Programming is, after all, a practical work, perfect design, such as the dream of beauty, can be pursued but difficult to reach." "The colon smiled," in fact, the key is not the number of services, but the consistency and relevance of services. Consistent service is a result of good abstraction and encapsulation, but also a guarantee of ' high aggregation and low coupling '. ”

"It's not easy being a service provider," he said. The question mark sighs, "then, as the service of the enjoyment of what is fastidious?" ”

The comma in the nasal cavity resonates: "Ha, do you need to pay attention to the service?" ”

"Of course there is. "The colon flatly says," as the service of the enjoyment, the most important thing is to tell the rules. To enjoy the services of others, we naturally have to follow the rules of others, otherwise the service will not be protected. For example, you can choose any item on the supermarket shelves, but you can't sneak into the cargo hold to pick it up. ”

The comma argued: "But the cargo hold wants to enter also can't go in." As with the appropriate encapsulation, guests are barred from entering the private interface. ”

The colon is quoted as saying: "We might as well assume that the front door of the cargo hold has a ' non-worker Mo ' sign." But you accidentally found that the end of the aisle leading to the bathroom was just the back door of the cargo hold, neither locked nor listed. Would you like to walk in? ”

Comma speechless.

Colon persuasion: "The supermarket staff may not be convenient for the map and open the back door, but that is the manager of the matter, as a customer obviously should not take advantage of." Goods from the cargo hold to the shelves before may have boxing, unpacking, barcode printing, barcode scanning and other operations, customers directly from the holding of goods will undoubtedly destroy this procedure, in the people have no benefit. Similarly, customers who act as other people's code should be reused in ways that others have designed to ensure the desired effect. It is the responsibility of the person responsible for supervising the quality of software that the other person's code effectively eliminates all possible vulnerabilities. ”

Quotation marks to understand: "This is like a customer to buy a product, but not according to the use of instructions to operate, resulting from all the consequences, manufacturers are not responsible for." ”

"That's the reason. "The colon hammers the table," Of course things are in Split. There is a common phenomenon in life: many pedestrians cross the guardrail and cross the road. On the one hand, pedestrians should obey the traffic rules and should not destroy the ' encapsulation ' of the road. On the other hand, some traffic designers are not "people-oriented" customer awareness, for pedestrians to provide pedestrian crossings, flyovers or tunnels too far apart. Objectively speaking, inadequate service is a major incentive for pedestrians to violate the rules. ”

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.