Solid Principles
solid-principles

Single Responsibility Principle (SRP)
Every class or function should have only one responsibility. For example, a TV remote should control only the TV, and an AC remote should control only the AC.
Open/Closed Principle (OCP)
Code should be designed in a way that allows new features to be added without modifying the existing code. For instance, a restaurant can add new items to the menu without changing the existing dishes.
Liskov Substitution Principle (LSP)
If a child class replaces a parent class, the system should continue to work smoothly. For example, both petrol and electric cars should drive in the same way.
Interface Segregation Principle (ISP)
Create small, specific interfaces for particular tasks. For instance, a printer should have separate buttons for print, scan, and fax.
Dependency Inversion Principle (DIP)
High-level modules should not depend on low-level details but rather on abstractions (like interfaces). For example, when you order food from a waiter, you don’t need to know the kitchen's process.
Leave a Comment
No comments yet. Be the first to comment!