Java and mode note (5) interface isolation principle

Source: Internet
Author: User

☆Interface isolation principle, it is better to use multiple special interfaces than to use a single total interface. In other words, from the perspective of a customer, the dependency of a class on another class should be built on the minimum interface.

9.1 what is interface isolation principle

☆The interface isolation principle is to provide different interfaces with different width and width for the same role to meet the requirements of different clients. The following example uses set as an example:

In this UML diagram, treeset is a sortable set container that uses a tree data structure. It implements both the Set interface (inherited abstractset) and the sortedset interface. This does not provide a general interface with both sorting and set functions. Instead, the two roles are defined as two interfaces based on different requirements, is in line with the interface isolation principle.

☆Interface pollution
Merging interfaces of different roles into a bloated interface is a pollution to the interface. This practice also violates the variability encapsulation principle, which encapsulates different variability into the same software entity.

☆For specific applications of the interface isolation principle, refer to the memorandum mode and iteration mode.

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.