ISP (interface segregation principle), interface isolation principle

Source: Internet
Author: User

ISP (interface segregation principle), interface isolation principle

 

The requirements are as follows:

① The dependence of one class on another class should be established on the minimum interface.

② It is better to use multiple special interfaces than to use a single total interface.

③ Unrelated interfaces cannot be merged into a bloated large interface.

④ A bloated large interface should be divided into several suitable small interfaces.

 

Interface separation method:

1. Use the delegate separation interface: delegate requests to the Implementation classes of other interfaces to fulfill the required responsibilities.

2. Use multiple inheritance and separation interfaces: implement multiple interfaces to fulfill the required responsibilities.

 

Summary:

Large interfaces lead to unnecessary Coupling Relationships between customer programs. The interface is designed according to the interface isolation principle, and the large interface is decomposed so that the customer program only depends on the method it needs. In terms of design, the interface is easy to maintain and highly reusable.

ISP (interface segregation principle), interface isolation principle

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.