Everyone needs SOLID code! Good programmers always strive to improve the code, making it more maintainable, easy to comprehend and extensible. These kind of improvements are generally carried out based on intuition and personal experiences in the past. However, wouldn’t it be great if every developer had some common set of rules to follow to make the code better.
This series of posts cover one of my favorite set of Software Development Principles – The SOLID Principles of Object Oriented Design and Development.
The term ‘SOLID’ was coined as an acronym for the set of Principles applicable when programming using Object Oriented languages. They were developed by Robert C Martin aka Uncle Bob.
The SOLID principles expose the dependency management aspects of OOD as opposed to the conceptualization and modeling aspects.
In Uncle Bob’s own words
Dependency Management is an issue that most of us have faced. Whenever we bring up on our screens a nasty batch of tangled legacy code, we are experiencing the results of poor dependency management. Poor dependency management leads to code that is hard to change, fragile, and non-reusable
On the other hand, when dependencies are well managed, the code remains flexible, robust, and reusable. So dependency management, and therefore these principles, are at the foundation of the -ilities that software developers desire.
Each of the letters in SOLID stand for a particular principle. Click on the links below to understand more about each principle. When the five rules are adhered to, it makes the code better.
I – Interface segregation principle
D – Dependency inversion principle
Note that the SOLID principles are the starting point for good code. It does not take away the fact that the code needs to be continuously refactored to keep it in good shape.
These principles and other fantastic stuff are covered in Uncle Bob’s great book on Software Development – Agile Software Development, Principles, Patterns, and Practices. The book is a bit dated now, but it is still worth read.
Let us know how SOLID your code is!