The SOLID principle aims to make code maintainable and extendable. It is itself composed of a set of principles, that form the acronym:
- S - Single responsibility principle: Do one thing, do it right. On OO module/class/function-level. Implies: If that one thing changes, only one thing (module/class/function) needs to be changed. Manageable complexity.
- O - Open/closed: Open for extension (yes, you can add more), but closed for modification (no changing of existing behavior). Nobody likes ever changing APIs that have them update their stuff.
- L - Liskov Substitution Principle: Subclasses should be usable instead of their parent classes. Basically: Inheritance is a thing and it works.
- I - Interface Segregation Principle: Don’t have one mega-interface, upon which then every client fully depends, but have many small interfaces, that reflect the clients actual use. Like need to know, just different.
- D - Dependency Inversion Principle: Always depend on abstractions (interfaces), never on specific implementations (like specific classes). Allows everyone to refactor, as long as the public interface stays the same.