0
0
LLDsystem_design~12 mins

Interface Segregation Principle in LLD - Architecture Diagram

Choose your learning style9 modes available
System Overview - Interface Segregation Principle

The Interface Segregation Principle (ISP) is a design guideline that suggests splitting large, general interfaces into smaller, more specific ones. This helps systems avoid forcing components to depend on methods they do not use, improving modularity and maintainability.

Key requirements include designing interfaces that are focused and tailored to client needs, reducing unnecessary dependencies, and enabling easier system evolution.

Architecture Diagram
  +----------------+       +----------------+       +----------------+
  |  Client A      |       |  Client B      |       |  Client C      |
  +-------+--------+       +-------+--------+       +-------+--------+
          |                        |                        |
          |                        |                        |
  +-------v--------+       +-------v--------+       +-------v--------+
  | Interface A    |       | Interface B    |       | Interface C    |
  | (Specific API) |       | (Specific API) |       | (Specific API) |
  +-------+--------+       +-------+--------+       +-------+--------+
          |                        |                        |
          +-----------+------------+------------+-----------+
                      |                         |
               +------v------+           +------v------+  
               | Service X   |           | Service Y   |  
               +-------------+           +-------------+  
Components
Client A
client
Uses Interface A to access specific service features it needs
Client B
client
Uses Interface B to access different specific features
Client C
client
Uses Interface C for yet another set of features
Interface A
interface
Defines a small, focused set of methods for Client A
Interface B
interface
Defines a small, focused set of methods for Client B
Interface C
interface
Defines a small, focused set of methods for Client C
Service X
service
Implements Interface A and Interface B to provide required features
Service Y
service
Implements Interface C to provide its specific features
Request Flow - 9 Hops
Client AInterface A
Interface AService X
Service XClient A
Client BInterface B
Interface BService X
Service XClient B
Client CInterface C
Interface CService Y
Service YClient C
Failure Scenario
Component Fails:Interface B
Impact:Client B cannot access Service X features through Interface B, causing failure in Client B's specific operations. Other clients and interfaces remain unaffected.
Mitigation:Implement fallback interfaces or degrade Client B features gracefully. Use interface versioning and monitoring to detect and fix issues quickly.
Architecture Quiz - 3 Questions
Test your understanding
Why does the system use multiple small interfaces instead of one large interface?
ATo make the system slower
BTo ensure clients only depend on methods they use
CTo force clients to implement all methods
DTo reduce the number of services
Design Principle
The Interface Segregation Principle improves system modularity by ensuring clients depend only on the interfaces relevant to them. This reduces unnecessary coupling and makes the system easier to maintain and extend.