SOLID principles

This repository contains the SOLID principles details and code examples written in JavaScript and Typescript.

Definition

SOLID is a mnemonic acronym for five design principles intended to make software designs more understandable, flexible, and maintainable.

The SOLID principles are:

[S] Single responsibility principle

There should never be more than one reason for a class to change. In other words, every class should have only one responsibility.

[O] Open–Closed principle

Software entities should be open for extension, but closed for modification.

[L] Liskov substitution principle

Functions that use pointers or references to base classes must be able to use objects of derived classes without knowing it. See also design by contract.

[I] Interface segregation principle

Many client-specific interfaces are better than one general-purpose interface.

[D] Dependency inversion principle

Depend upon abstractions, not concretions.

👆 Source

Code examples

Principle Information
Single responsibility 📄
Open–Closed 📄
Liskov substitution 📄
Interface segregation 📄
Dependency inversion 📄