SOLID Principles of Software Design
October 06, 2023 by Jane

SOLID

Single Responsibility - each class should only do one thing. This is linked to coupling and cohesion amongst classes

Open/Closed Principle - each module should be flexible enough to accomodate different inputs without changes. If there's drastic changes the preference is to extend the code not modify it for backwards compatibility.

Liskov Substitution Principle - all subclass objects should be able to subsitute their parents, if inheriting an interface or a parent class, completely implement the interface.

Interface Segregation Principle - have smaller interfaces that are highly cohesive, then stitch them together with multiple inheritance when you need to use functionality from more than one interface. It's better than having a fat interface that the client doesn't really need and is stuck with awkward choice of implementing the whole interface when it doesn't need to so as to avoid violating the Liskov Substitution Principle or violating the Liskov Substitution Principle for efficiency and creating mines that might hurt themselves later on.

Dependency Inversion Principle - aim to build a system that is modular, loosely-coupled, and easily tested (having module and loosely-coupled helps with modular testing). This can usually be done by abstracting modules with interfaces so that the business logic doesn't interact with each other directly.