SOLID - alexanderteplov/computer-science GitHub Wiki

SOLID principles

S = Single Responsibility Principle

For any changes in a module, there should be only a single reason.

O = Open-closed Principle

An interface should be open to extension and closed to changes.

L = Liskov (Barbara) Substitution Principle

All instances of a superclass can be substituted by instances of their subclasses.

So preconditions of a superclass can't be strengthened, and postconditions can't be weakened in a subclass.

It's one of the most important reasons for tight coupling.

I = Interface Segregation Principle

Subclass shouldn't inherit useless methods. In cases of a lot of in common, it's better to segregate a common interface and inherit both from it.

D = Dependency Inversion Principle

Modules shouldn't depend on details.

A general shouldn't depend on a particular (specific).

If your module for establishing a database connection depends on a particular DB driver - it's a problem.

Both general and particular should depend on abstractions.

(So, create an interface for DB drivers.)

Links

⚠️ **GitHub.com Fallback** ⚠️