Series: Understanding software architecture and design ?
Episode 3: Principles of Good Software Design
The key principles of good software design helps to create software that is reliable, maintainable, and efficient, and that can adapt to future changes and requirements.
1. Modularity: Break the software into small, independent pieces (modules) that each do one thing well. This makes the software easier to understand, develop, and maintain.
2. Encapsulation: Hide the internal workings of a module from the outside world. Only expose what is necessary. This keeps different parts of the software from interfering with each other.
3. Separation of Concerns: Divide the software so that different parts handle different tasks. This reduces complexity and makes it easier to manage.
4. Single Responsibility Principle: Each module or class should have one job or responsibility. This makes the software easier to understand and change.
5. Open/Closed Principle: Software should be open for extension but closed for modification. You should be able to add new features without changing existing code.
6. DRY (Don't Repeat Yourself): Avoid duplicating code. Instead, reuse code wherever possible. This makes the software easier to maintain and reduces the risk of errors.
Recommended by LinkedIn
7. KISS (Keep It Simple, Stupid): Keep the design as simple as possible. Avoid unnecessary complexity. Simple designs are easier to understand and maintain.
8. YAGNI (You Aren't Gonna Need It): Don’t add features or components until they are actually needed. This prevents unnecessary complexity and keeps the software lean.
9. High Cohesion and Low Coupling: Aim for high cohesion within modules (related tasks grouped together) and low coupling between modules (minimal dependencies on each other). This makes the software more robust and easier to maintain.
10. Scalability: Design the software so it can handle increased load or be easily expanded in the future. This ensures the software can grow with user needs.
11. Maintainability: Write code that is easy to understand, modify, and extend. Use clear naming, comments, and consistent formatting to make the software easy to work with over time.
12. Testability: Design the software so it can be easily tested. Write automated tests to verify that each part of the software works correctly. This helps catch bugs early and ensures the software remains reliable.