SOLID & OOP Principles (50 Qs)•Part 3: Enterprise Architecture, Package Design & Enforcement (25 - 35)
Interface Segregation Principle (ISP) vs Fat Interfaces.
senior LevelTypeScriptSystem Design
In Simple Words: "Clients should not be forced to depend upon interfaces that they do not use":
- Fat Interface Anti-Pattern: An
AllInOnePrinterinterface declaringprint(),scan(),fax(), andstaple(). A basic office printer implementing this interface must implement empty stubs or throwUnsupportedOperationExceptionfor scanning and stapling! - Role Interfaces: Split into lean, granular capabilities:
Printer { print() }Scanner { scan() }FaxMachine { fax() }
- Classes implement only the specific interfaces matching their true capabilities.