First Principles of Object-Oriented Design
Sep 7, 2018 · 1 min read
Express intent is the most important thing. A code should convey itself what is happening around with the logic. Naming variables, methods and proper commits and BDD are all part of expressing the intention behind the code.
Then the most important principle is SOLID —
1. Single-responsibility principle
There should be never more than one reason for a class to change.
2. Open-closed principle
There should be no modification of classes, only extending of features. Have loose coupling.
3. Liskov substitution principle
Objects should be replaceable by instances of their subtypes, and that without affecting the functioning of your system.
4. Interface segregation principle
Classes that implement interfaces, should not be forced to implement methods they do not use.
5. Dependency Inversion Principle
High level modules should not depend on low level modules rather both should depend on abstraction.