We usually write code that is-
- Rigid – Difficult to add new features
- Fragile – Unable to identify the impact of the change
- Immobile – No reusability
- Viscous – Going with the flow of bad practices already being present in the code.
There have been lot of principles for writing good code and all these principles define how the code manages the dependency. Most of them are aware of the principles:
- Loosely coupled code – There shouldn’t be too much of dependency between the modules, even if there is a dependency it should be via the interfaces and should be minimal.
- Highly cohesive code- The code has to be very specific in its operations.
- Context independent code- So that it can be reused.
- DRY – Dont repeat yourself – Avoid copy-paste of code. Change in the code would have to be made in all the places where its been copied.
SOLID stands for:
In subsequent posts I would be writing about the individual principles. The following presentation was prepared by me for a talk on SOLID principles: