Interface Isolation principle (Interface segregation Principle) ISP Basic Concept interface
- instance Interface (Object Interface): An instance object of a class is a description of a type of thing, an interface.
- class Interface: The interface of Interface key definitions in Java, the narrow interface we usually understand
ISP definition
Guarantee
Interface PurityThe specification
Guaranteed interface
Atomic NatureThe specification
- One interface serves only one submodule or business logic
- Compress public methods by optimizing business logic
The size of the interface is too small, resulting in an increase in the number of interfaces, unfriendly to the developer, the size of the interface is too large, the flexibility is reduced, can not provide customized services to the overall project to create an unpredictable risk. Example ISP
Define a scene, that is, when you are looking for a job, the screening of resumes, people have specificity, if the interface of the grain through the large, it may not be able to make a full presentation of the skills, or have to brag to ensure that all of their skills are involved ( because the granularity is not refined ), may also be divided Interface fine spent in large , fill resume and write a book the same cost, where there will be someone to apply for, to sell the book is not good ~ it is not realized, completely without any code difficulty ....
Often the granularity of the interface is inappropriate and
the scene is closely related, it depends on the designer's ability, and some design patterns are widely used and their interface design is just right.
Java design mode (13) interface Isolation principle (ISP)