SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.
SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.
Successfully reported this slideshow.
Activate your 14 day free trial to unlock unlimited reading.
1.
SOLID Principles
Presented by Mónica Rodrigues
January 24rd, 2017
2.
Contents ➢ What is SOLID
➢ Single responsibility Principle
➢ Open/Closed Principle
➢ Liskov Substitution Principle
➢ Interface Segregation Principle
➢ Dependency Inversion Principle
3.
Who am I?
Mónica Rodrigues
Degree in Computer Science Engineer at ISEL
Software engineer since 2009
Keywords: Web Applications, ASP.NET MVC, ASP.NET Web API, REST,
Javascript, Angular, Best practices, Design patterns, SQL Server and
much more..
4.
What is SOLID?
S
SRP
Single
Responsibility
Principle
O
OCP
Open/Closed
Principle
L
LSP
Liskovs
Substitution
Principle
I
ISP
Interface
Segregation
Principle
D
DIP
Dependency
Inversion
Principle
5.
“A class should have one and
only one reason to change”
Single Responsibility Principle
6.
Single Responsibility Principle
Business logic
Persistence
There are two
responsibilities
7.
Single Responsibility Principle
How to solve this?
8.
Single Responsibility Principle
Just create two different
classes
9.
Open/Closed Principle
“Software entities should be
open for extension, but
closed for modification.”
10.
Open/Closed Principle
Humm...and if I need to
add a new payment type?
You need to modificate
this class.
11.
Open/Closed Principle
open for
extension
close for
modification
12.
Liskov Substitution Principle
“Let q(x) be a property provable about
objects x of type T. Then q(y) should
be provable for objects y of type S
where S is a subtype of T”
What do you say?
13.
Liskov Substitution Principle
“A subclass should behave in such a
way that it will not cause problems
when used instead of the
superclass.”
22.
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.”
23.
Dependency Inversion Principle
And if I need to send a
notification by SMS?
You need to change this.
24.
Dependency Inversion Principle
So, I create an
interface and now?