Skip to content

09u/solid-principles-with-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

SOLID is one of the most popular design principles in object-oriented software development. It is a mnemonic abbreviation of the following five design principles:

  • Single Responsibility Principle: a class should have one and only one reason to change, meaning that a class should have only one job.

  • Open/Closed Principle: objects or entities should be open for extension but closed for modification.

  • Liskov Substitution Principle: let q(x) be a property provable about objects of x of type T. Then q(y) should be provable for objects y of type S where S is a subtype of T.

  • Interface Segregation Principle: a client should never be forced to implement an interface that it doesn’t use, or clients shouldn’t be forced to depend on methods they do not use.

  • Dependency Inversion Principle: entities must depend on abstractions, not on concretions. It states that the high-level module must not depend on the low-level module, but they should depend on abstractions.

Different software languages in the Example folder have code snippets that show how applying SOLID principles affects code design.

For each principle, there are two files in the Sources folder;

  • bad files: a default implementation of sample case

  • good files: related principle applied version of the case

to show the difference in a simple and clear way.

P.S.: thanks to digitalocean SOLID principle article.