0
0
LLDsystem_design~12 mins

Open/Closed Principle in LLD - Architecture Diagram

Choose your learning style9 modes available
System Overview - Open/Closed Principle

The Open/Closed Principle is a software design guideline that states software entities like classes, modules, and functions should be open for extension but closed for modification. This means you can add new features without changing existing code, reducing bugs and improving maintainability.

Key requirements include designing components that allow behavior to be extended without altering their source code, often using abstraction and polymorphism.

Architecture Diagram
          +----------------+
          |   Client App   |
          +--------+-------+
                   |
                   v
          +--------+-------+
          |  Abstract Base |
          |   Component    |
          +--------+-------+
                   |
      +------------+-------------+
      |                          |
+-----+-----+              +-----+-----+
| Extension |              | Extension |
|  Module A |              |  Module B |
+-----------+              +-----------+
                   |
                   v
          +--------+-------+
          |   Core System  |
          +----------------+
Components
Client App
client
Sends requests to the system and uses components
Abstract Base Component
abstraction
Defines common interface and behavior for extensions
Extension Module A
service
Adds new behavior by extending the base component without modifying it
Extension Module B
service
Another extension adding different behavior following the same interface
Core System
system
Uses the abstract base and extensions to fulfill client requests
Request Flow - 5 Hops
Client AppCore System
Core SystemAbstract Base Component
Abstract Base ComponentExtension Module A or B
Extension Module A or BCore System
Core SystemClient App
Failure Scenario
Component Fails:Extension Module A
Impact:Operations relying on Extension Module A fail or produce errors, but other extensions and core system remain functional
Mitigation:Core System can fallback to default behavior in Abstract Base Component or use other extension modules; errors are isolated to failing extension
Architecture Quiz - 3 Questions
Test your understanding
Which component allows adding new features without changing existing code?
AClient App
BExtension Modules
CAbstract Base Component
DCore System
Design Principle
This architecture shows how the Open/Closed Principle enables adding new features by creating new extension modules that implement a common interface, avoiding changes to existing code and reducing risk of bugs.