SOLID Design Principles
SOLID is an acronym for design principles, let's look at it
- Single Responsibility Principle
- A class should have one and only one reason to change
- Open Closed Principle
- The class can be extended without modifying it. So it's open for extension and closes for modification
- Liskov Substitution Principle
- Subclasses should be able to replaceable by their base types without affecting existing implementation
- Interface Segregation Principle
- Many interfaces are better than one general interface
- Dependency Inversion Principle
- Depend on abstraction, not on concretions
SOLID principles are a time-tested solution for software design problems. This principle helps to achieve loosely coupled code design.
Common problems in software architecture?
- A poor architecture will develop bugs over time
- the application requires to be altered for all the customization and future extensions
- Once the application is ready and in production, over time it takes a lot of effort even for a simple task
- Creating a single class with a lot of responsibility
- Unnecessary dependency between classes
- Redundant code
Why we should use SOLID design principles?
- SOLID principles help to solve above listed common problems
- Provides loosely coupled architecture
- Classes can have their specific responsibility
- Rather than extending the one class using inheritance and abstraction, we can achieve the reusable environment
- It stops affecting the existing functionality
- It allows focusing more on abstraction
We will go into detail in each dedicated post. Let me know if you have any suggestions or feedback.
No comments:
Post a Comment