Stage 2 · Lesson 4 of 7
Interface segregation
The says clients should not depend on methods they do not use. A single Machine interface with print, scan and fax forces a basic printer to implement fax, usually by throwing an error, which also breaks Liskov substitution.
Splitting it into Printer, Scanner and Fax lets each class implement only what it really does, and lets each caller ask for only what it needs. Small interfaces also make tiny: a Printer needs one method. Design interfaces from the caller's side: what does this code need from its collaborator?
Common trapgoing the other way and splitting every interface into one-method pieces that no caller ever uses separately, which adds names without adding clarity.
A question to check yourself, an AI practice session and 1 cheat sheet entry come with the full roadmap. Unlock
Resources for this stage
Start with· follow one of these
- CoursePaidGrokking SOLID Design Principles
Design Gurus · Beginner · $50 one-time
One chapter per principle, each with the violation and the refactoring that fixes it
- CourseFreeMIT 6.102: Software Construction
MIT · Intermediate
Free: the Specifications and Interfaces and Subtyping readings explain substitution as contracts