InterfaceSegregation
Interface Segregation Principle (ISP) is a design principle in object-oriented programming and one of the SOLID principles. It states that no client should be forced to depend on methods it does not use. To achieve this, interfaces should be small and specific rather than large and general-purpose.
Rationale and benefits: By splitting broad interfaces into smaller, cohesive ones, implementations only commit to the
Examples: A common example is a Worker interface with methods work() and eat(). If a class only
Implementation guidance: Analyze responsibilities and break large interfaces into smaller, task-specific ones. Prefer composition over a
Impact: ISP promotes modular, maintainable, and testable code by reducing forced dependencies and enabling flexible reuse