SOLID Principles
Five core object-oriented design principles. Each page shows the violating ("before") code next to the fixed ("after") code, with a toggle.
S
#01
Single Responsibility Principle
A class should have only one reason to change. Splitting order-processing logic out of the controller into a dedicated service.
Open demo →
O
#02
Open/Closed Principle
Classes should be open for extension but closed for modification. Adding new shapes without editing the AreaCalculator.
Open demo →
L
#03
Liskov Substitution Principle
Subtypes must be substitutable for their base types without breaking the application.
Open demo →
I
#04
Interface Segregation Principle
No client should be forced to depend on methods it does not use. Splitting a bloated Orderable interface into focused ones.
Open demo →
D
#05
Dependency Inversion Principle
Depend on abstractions, not concretions. OrderProcessingService depends on repository interfaces, not MySQL classes.
Open demo →