backSolid Summary in notes
2022-03-02
SOLID are guiding principles to organize functions, modules and classes.
SRP states there should be one reason for a module to change. Stakeholders are usually the reason to changes. The principle is voilated if change in one module affects code other stakeholders depend upon.
The core of a good software is any extension should only cause small changes. This could be acheived by organizing the dependencies and ensuring changes to one component does not affect others.
The dependencies are unidirectional creating a notion of layers or levels. Modules at the higher level are protected from changes introduced at the lower level.
A program's behaviour is unchanged when an object of type T is replaced with object of type S, where S is a subtype of T. Voilations:
A type should not depend on behaviours it doesn't use. A class `Employee` depends on a framework F, F in turn depends on X. Some feature of the X is not used. If the unused feature breaks which would inturn break F and Employee.
Fleixble system should depend on abstraction instead of concretion. But dependeing upon concrete dependencies are inevitable. For example, the OS is usually a stable dependency. We are worries about dependencies that are volatile, which are under