10ISP: THE INTERFACE SEGREGATION PRINCIPLE

Image

The Interface Segregation Principle (ISP) derives its name from the diagram shown in Figure 10.1.

Image

Figure 10.1 The Interface Segregation Principle

In the situation illustrated in Figure 10.1, there are several users who use the operations of the OPS class. Let’s assume that User1 uses only op1, User2 uses only op2, and User3 uses only op3.

Now imagine that OPS is a class written in a language like Java. Clearly, in that case, the source code of User1 will inadvertently depend on op2 and op3, even though ...

Get Clean Architecture: A Craftsman's Guide to Software Structure and Design, First Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.