Embrace the principle, not an architecture
The principles when applied together intend to make it more likely that a programmer will create a system that is easy to maintain and extend over time.
SOLID Principles is a coding standard for developing software in a proper way to avoid a bad design. It was promoted by Robert C Martin and is used across the object-oriented design spectrum. When applied properly it makes your code more extendable, maintainable, logical and easier to read.
What is principle in SOLID principles?
The SOLID principles are not rules, they are not laws and they are not perfect truths. This is a advice for a good software design which is not rigid and fragile.
Knowledge of the principles and patterns gives you the justification to decide when and where to apply them. If you don’t know them, your decisions are much more arbitrary.
SOLID is a acronym for five design principles intended to make software designs more understandable, flexible and maintainable. SOLID principles were introduced by Martin in 2000.
You will come across two terms “rigidity” and “fragility” while reading about principles.
Let’s discuss what are they:
Rigidity: Software becomes difficult to change when changes causes other changes in dependent modules which are irrelevant. Simple changes become expensive.
Rigid code is the code that has dependencies that snake out in so many directions that you cannot make an isolated change without changing everything else around it.
— Robert Martin
For instance, you try to change some low-level detail in the data layer, and all of a sudden you get a compile error in the class that does the formatting for your View. If you often find yourself touching almost all the files of your project, whenever you make changes in a single class, it’s a symptom of rigid code.
Fragility: Fragile code is more worser than agile code as it doesn’t produce compile time error. Fixes introduce new bugs which contribute in regression issues.
Fragile code breaks in strange ways that you cannot predict.
— Robert Martin
Explaining principles here is too vast. I am going to dedicate individual posts for these principles.