Table of Contents
Introduction
Software design principles are a set of guidelines that helps us to avoid the bad design of a solution. The software designs helps to make a software well designed, well read and best maintainable.
The design principles are associated to Robert Martin who gathered all the design principles in his book "Agile Software Development: Principles, patterns and practices".
Some characteristics of bad design
1. Rigidity - It implies that it is very hard to change anything in the code as every change affects too many other parts of the system. In the beginning of the simple change, it might seem that it might take a small time to change the logic, but with a rigid software model, the cascading changes on dependent modules takes engineers a hell lot of time that grows subsequently giving lot of grief to the developers. This is the type of development where manager fears to make any changes to the project.
2. Fragility - It implies, making a change is too risky. When some changes are made, it makes other part of the system break. Often the breakage occurs in areas where there is no conceptual relationship with the area that has been changed. As fragility becomes worse over time, managers decide not to make any changes to the project and declare the project as unmaintainable.
3. Immobility - It makes an application hard to mobile. That means, when building another application, it is very hard to reuse the same code in another application because it cannot be disentangled from the current application that easy. There could be also an element of risk involved while separating the desirable part of the software.
4. Viscosity : Viscosity in an application comes in two ways. One is viscosity in design and viscosity in environment. Viscosity in design comes when a developer finds more than one way to make changes to the application and the way to face the change is harder to preserve the design. In other words, say a developer need a certain change in the application and he finds the hack to the application which can fix the problem is much easier than that of the one which preserve the design of the application in which it is build in, is said to viscous. Viscosity in environment is when the environment is not suitable in preserving the existing design of the application. For instance, say certain changes in files makes it pretty long time to compile etc.
These four symptoms are signs of poor architecture. To avoid such symptoms in an application, it is recommended to employ certain design principles.
SOLID Principles
SOLID principles are set of rules first introduced by Michael Feathers for the "First five principles" which later identified by Robert C Martin in early 2000s. These stands out as the acronym for the five basic principles of Object oriented programming and design. The principles ensures that when it is correctly maintained over time, the programmer have to face lesser amount of problems while maintaining the application and the program itself will remain capable of extension. The Solid principles intend to remove code smells causing the programmer to refactor their code and make it well maintainable and extendable. The SOLID principles are mostly applied in Test Driven development and the overall strategy is adaptive programming.
The Acronym SOLID is taken from the first letter of these five principles.
1. Single Responsibility Principle
2. Open Close Principle
3. Liskov's Substitution Principle
4. Interface Segregation Principle
5. Dependency Inversion Principle
These 5 principles are sometimes combined and regarded as SOLID Principle in object oriented design taking the initials of each of the principles. These makes a mark in Robert Martins categorization on Class Design Principles.
Some other Principles
1. Package Cohesion Principles
2. Package Coupling Principles
Software design principles are pretty much a vast topic and any developer starting developing a real world app should consider them before start of the project.
Miscellaneous principles which are worth mentioning
- Program to Interface Not Implementation.
- Don't Repeat Yourself.
- Encapsulate What Varies.
- Depend on Abstractions, Not Concrete classes.
- Least Knowledge Principle.
- Favor Composition over Inheritance.
- Hollywood Principle.
- Apply Design Pattern wherever possible.
- Strive for Loosely Coupled System.
- Keep it Simple and Sweet / Stupid.
The principles are self explanatory.