notes/Media/articles/S.O.L.I.D. Principles - DEV Community.md
2023-08-06 21:42:41 +02:00

5.6 KiB
Raw Blame History

author link status date
twitter:Trekhleb https://dev.to/trekhleb/s-o-l-i-d-principles-around-you-1o17 not-finished August 2, 2023

S.O.L.I.D. Principles Around You - DEV Community

#programming #software-development #object-oriented-design Cover image for S.O.L.I.D. Principles Around You

In this article, I want to briefly go through SOLID principles (the acronym that stands for five basic principles of object-oriented programming and design) supplying each of them with real-world visual examples to make those principles more understandable, readable and memorizable.

If you want to see code examples instead you may take a look at variety of tree data structure implementations in JavaScript like Binary Search Tree, AVL Tree, Red-Black Tree, Segment Tree or Fenwick Tree.

So lets move on!

S — Single Responsibility Principle

a.k.a [SRP](https://en.wikipedia.org/wiki/Single_responsibility_principle)

Single Responsibility Principle

O — Open/Closed Principle

a.k.a [OCP](https://en.wikipedia.org/wiki/Open/closed_principle)

Open/Closed Principle

L — Liskov Substitution Principle

a.k.a. [LSP](https://en.wikipedia.org/wiki/Liskov_substitution_principle)

Liskov Substitution Principle

I — Interface Segregation Principle

a.k.a. [ISP](https://en.wikipedia.org/wiki/Interface_segregation_principle)

Interface Segregation Principle

D — Dependency Inversion Principle

a.k.a. [DIP](https://en.wikipedia.org/wiki/Dependency_inversion_principle)
  • High-level modules should not depend on low-level modules. Both should depend on abstractions.
  • Abstractions should not depend on details. Details should depend on abstractions.

Dependency Inversion Principle

The plug doesnt care which type of wire it uses, it just needs wires that conduct electricity.

I hope these illustrations have been useful for you :)