First Principles of Object-Oriented Design

Daval Pargal
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.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade