Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

SOLID Design Principles

SOLID Stands For

•Single responsibility
•Open-closed
•Liskov substitution
•Interface segregation
•Dependency inversion

The principles, when applied together, intend to make


easy to maintain and extend over time system
S – SRP - Single responsibility principle

Every class, function, variable should define a single


responsibility, and that responsibility should be
entirely encapsulated by the context

It is important to keep a class focused on a single


concern is that it makes the class more robust
O –OCP - Open/closed principle

software entities (classes, modules, functions,


etc.) should be open for extension, but closed for
modification that is, such an entity can allow its
behavior to be extended without modifying its
source code

This is especially valuable in a production


environment, where changes to source code may
necessitate code reviews, unit tests, and other
such procedures to qualify it for use in a product
L – LSP - Liskov substitution principle

It is a particular definition of a subtyping


relation, called behavioral subtyping

If S is a subtype of T, then objects of type T


may be replaced with objects of type S
without altering any of the desirable
properties of that program
I – ISP - Interface segregation principle

It states that no client should be forced to


depend on methods it does not use

ISP splits interfaces which are very large into


smaller and more specific ones so that clients
will only have to know about the methods
that are of interest to them
D – DIP - 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.
SOLID Design Principles
(In Brief)
Very important for exam :

1- Single Responsibility Principle :


A class should have one and only one reason to change

2- Open/Closed Principle :
Software entities should be open for extension, but closed for modification

3-Liskov Substitution Principle :


A subclass should behave in such a way that it will not cause problems when used
instead of the superclass

4-Interface Segregation Principle :


Clients should not be forced to depend upon interfaces that they don't use

5-Dependency Inversion Principle :


High-level modules should not depend on low-level modules. Both should depend on
abstractions Abstractions should not depend upon details. Details should depend
upon abstractions
THANK YOU!

You might also like