Interface segregation principle

We've already discussed the important role played by abstractions in object-oriented design. The abstractions and their derived classes without separation usually come up with hierarchical tree structures. That means when you choose to create a branch, you create a parallel abstraction to all of those on another branch.

For a family of classes with only one level of inheritance, this is not a problem: because it is just what you want to have those classes derived from. But for a hierarchy with greater depth, it could be.

Example

Consider the TextReader example we took with Template Method Pattern in Chapter 6, Behavioral Design Patterns: Continuous we had FileAsciiTextReader and HttpAsciiTextReader derived from AsciiTextReader ...

Get TypeScript Design Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.