SOLID & OOP Principles (50 Qs)•Part 3: Enterprise Architecture, Package Design & Enforcement (25 - 35)
Interface Pollution and YAGNI: Detecting premature abstraction.
senior LevelTypeScriptSystem Design
In Simple Words:
- Interface Pollution Anti-Pattern: Creating an
IUserServiceinterface for every singleUserServicewhen there is only ever one concrete implementation and zero intention of creating another. - Creates indirection, requires clicking through two files in IDEs, and provides zero business value.
- Rule of Thumb: Do not extract an interface until you have at least two distinct implementations (e.g. real vs mock, or Stripe vs PayPal), or when crossing architectural boundaries (domain core to external database).