SlideShare ist ein Scribd-Unternehmen logo
1 von 33
Downloaden Sie, um offline zu lesen
The OO Design PrinciplesThe OO Design Principles
Agenda
Need of Design
Design Smells
2
Class Design Principles
Summary
Agenda
Need of Design
Design Smells
3
Class Design Principles
Summary
What's meaning
of design..?
What's the different
compared to
Design is
about how
What Design Exactly About is..?
4
compared to
analysis..?
Analysis is
about what
Why do we
Need
Design..?
To deliver
faster
To manage
change
Why do we need design..?
5
change
To deal with
complexity
Agenda
Need of Design
Design Smells
6
Class Design Principles
Summary
Okay... I under stand the
Importance of design
How do we know a
Design is bad..?
Design Smells
7
Are they any symptoms
Of bad design...
Immobility
Viscosity
Rigidity
Fragility
Design Smells(contd
)
8
ViscosityFragility
Rigidity
Tendency for software to be difficult to change.
The design is hard to change
9
Tendency for software to be difficult to change.
Single change causes cascade of subsequent changes in
dependent modules.
The more module must be changed the more rigid the
design.
Fragility
Tendency of the software to break in many places every
The design is easy to break
10
Tendency of the software to break in many places every
time it's changed .
The breakage occurs in areas with no conceptual
relationship
On every fix the software breaks in unexpected way.
Immobility
Inability to reuse software from other projects or modules .
Difficult to reuse
11
Inability to reuse software from other projects or modules .
The useful module have to many dependencies.
Cost of rewriting is less compared to the risk faced to
separate those part.
Viscosity
It's easy to do the wrong thing, but hard to do the right
Hard to do the right thing
12
It's easy to do the wrong thing, but hard to do the right
thing.
When the design preserving methods are more difficult to
use then the hacks
When dev environment is slow and inefficient developer
will be tempted to do wrong things.
Why design becomes rigid,
Fragile Immobile and viscousIs there any
Characteristics
For good design
Design Characteristics
13
High cohesion
Improper
dependencies
Between modules
Design Characteristics
14
Low coupling
So how can we
Achieve good
Design..?
SRP
LSP
OCP
Design Characteristics
15
ISP
DIP
So let's go SOLID..
Single Responsibility Principle
There should never be more then one reason
This is hard to see, as we think
Responsibility in group
16
There should never be more then one reason
to change a class.
Many responsibility means many reason to
change.
1. Removes the immobility Smell from
Design.
2. Deodorizes the Rigidity Smell
Ohh.. SRP
Benefits of SRP
17
Open Closed Principle
Software entities should be open for extension, but closed for
Abstraction is the key
18
Software entities should be open for extension, but closed for
modification.
Keep the things that change frequently away from things that
don't change.
Open Closed Principle (contd
)
Open for Extension
Behavior of the module
can be extended.
Closed for Modification
The source of such a module
is invisible.
OCP is the heart of object oriented design
19
Make the module behave
in new and different ways
as the requirement of the
application change.
Resist making source change
to it.
Is 100%
Closer
possible
Is there any
techniques
In Reality 100% Closer
is not attainable.
Closer must be
Strategic.
Abstraction is the key
Further thinking of OCP
20
Flexibility, re usability
and maintainability is
The benefits
Liskov's SubstitutionPrinciple
LSP defines the inheritance principle.
Subclass should be substitutable for their base class
21
LSP defines the inheritance principle.
It makes clear that in OO design IS-A relationship is about
behavior; behavior that clients depend on.
If client uses a base class, then it should not differentiate
the base class.
LSP Violation Example
void g(Rectangle r)
{
r.setWidth(5);
r.setHeight(4);
if(r.getArea() != 20)
throw new
Exception("Bad area!");
Square is not
Rectangle!
22
Exception("Bad area!");
}
IS-A Relationship
Square’s behavior is
changed, so it is not
substitutable to
Rectangle
Further thinking of LSP
In order to be substitutable, the contract of the base class
must be honored by the derived class.
Derived class substitutable or base class, if
Design by Contract
23
Derived class substitutable or base class, if
Preconditions are no stronger then the base class
Preconditions are no weaker then the base class
Derived method should expect no more and provide no less
LSP Violation
The solution will likely to be put into an if else statement in the
client side.
Are you sure it works?
What happen if new
derivatives of rectangle
come..?
May be we've allocate
24
May be we've allocate
The responsibility
Wrongly.
It violates OCP
Interface Segregation Principle
Client should not forced to depend on methods they do not
Many client specific interface are Better then one
general purpose interface
25
Client should not forced to depend on methods they do not
use.
ISP deals with designing cohesive interfaces and avoiding
fat interfaces.
What happen when the big class changes? All depending
module must also change.
Service
<<Client A methods>>
+ ...
<<Client B methods>>
+ ...
<<Client C methods>>
+ ...
Client A
Client B
An violation of ISP example
26
ISP violation
Client C
Segregated
interface
Service
<<Interface>>
Service A
<<Client A methods>>
+ ..
<<Interface>>
Service B
Client A
An violation of ISP example: Solution
27
<<Client A methods>>
+ ...
<<Client B methods>>
+ ...
<<Client C methods>>
+ ...
Service B
<<Client B methods>>
+ ..
<<Interface>>
Service C
<<Client C methods>>
+ ..
Client B
Client C
Dependency Inversion Principle
High level module should not depend upon low level
Depend upon abstraction. Do not depend
Upon concretions
28
High level module should not depend upon low level
modules, both should depends upon abstraction
Abstraction should not depends upon on details, details
should depends on abstraction.
DIP
A DIP example
29
DIP
violation
DIP Summary
Inversion of dependencies is the hallmark of good object
oriented design.
If it's dependencies are inverted, it has an OO design If it's
dependencies are not inverted it has a procedural design.
Dependency injection is the core of the famous spring
30
Dependency injection is the core of the famous spring
framework
Hollywood principle: “ Don't call us, we'll call you”.
Summary
‱ A class should have only one reason to changeSRP
‱ A Module should be open for extension but
closed for modification.OCP
‱ Subclass should be substitutable for their base
LSP
31
‱ Subclass should be substitutable for their base
class.LSP
‱ Many client specific interfaces are better then
one general purpose interface .ISP
‱ Depends upon abstraction. Do not depends
upon concretions.DIP
Questions ???Questions ???
Solid Principle

Weitere Àhnliche Inhalte

Was ist angesagt?

ç‰©ä»¶ć°Žć‘èš­èšˆćŽŸć‰‡ïŒšSOLID + DI
ç‰©ä»¶ć°Žć‘èš­èšˆćŽŸć‰‡ïŒšSOLID + DIç‰©ä»¶ć°Žć‘èš­èšˆćŽŸć‰‡ïŒšSOLID + DI
ç‰©ä»¶ć°Žć‘èš­èšˆćŽŸć‰‡ïŒšSOLID + DIJeff Chu
 
principles of object oriented class design
principles of object oriented class designprinciples of object oriented class design
principles of object oriented class designNeetu Mishra
 
Design principles - SOLID
Design principles - SOLIDDesign principles - SOLID
Design principles - SOLIDPranalee Rokde
 
SOLID Principles
SOLID PrinciplesSOLID Principles
SOLID Principlesakbarashaikh
 
Clean architecture
Clean architectureClean architecture
Clean architecture.NET Crowd
 
SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design PrinciplesAndreas Enbohm
 
Object Oriented Programming (OOP) Introduction
Object Oriented Programming (OOP) IntroductionObject Oriented Programming (OOP) Introduction
Object Oriented Programming (OOP) IntroductionSamuelAnsong6
 
Single Responsibility Principle
Single Responsibility PrincipleSingle Responsibility Principle
Single Responsibility PrincipleEyal Golan
 
Solid principles
Solid principlesSolid principles
Solid principlesDeclan Whelan
 
Open Closed Principle kata
Open Closed Principle kataOpen Closed Principle kata
Open Closed Principle kataPaul Blundell
 
Clean code: SOLID (iOS)
Clean code: SOLID (iOS)Clean code: SOLID (iOS)
Clean code: SOLID (iOS)Maksym Husar
 
Clean Architecture
Clean ArchitectureClean Architecture
Clean ArchitectureBadoo
 
Solid design principles
Solid design principlesSolid design principles
Solid design principlesMahmoud Asadi
 

Was ist angesagt? (20)

SOLID principles
SOLID principlesSOLID principles
SOLID principles
 
Solid Principles
Solid PrinciplesSolid Principles
Solid Principles
 
Clean code: SOLID
Clean code: SOLIDClean code: SOLID
Clean code: SOLID
 
ç‰©ä»¶ć°Žć‘èš­èšˆćŽŸć‰‡ïŒšSOLID + DI
ç‰©ä»¶ć°Žć‘èš­èšˆćŽŸć‰‡ïŒšSOLID + DIç‰©ä»¶ć°Žć‘èš­èšˆćŽŸć‰‡ïŒšSOLID + DI
ç‰©ä»¶ć°Žć‘èš­èšˆćŽŸć‰‡ïŒšSOLID + DI
 
SOLID
SOLIDSOLID
SOLID
 
principles of object oriented class design
principles of object oriented class designprinciples of object oriented class design
principles of object oriented class design
 
Design principles - SOLID
Design principles - SOLIDDesign principles - SOLID
Design principles - SOLID
 
SOLID Principles
SOLID PrinciplesSOLID Principles
SOLID Principles
 
Clean architecture
Clean architectureClean architecture
Clean architecture
 
SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design Principles
 
Object Oriented Programming (OOP) Introduction
Object Oriented Programming (OOP) IntroductionObject Oriented Programming (OOP) Introduction
Object Oriented Programming (OOP) Introduction
 
Single Responsibility Principle
Single Responsibility PrincipleSingle Responsibility Principle
Single Responsibility Principle
 
SOLID Principles
SOLID PrinciplesSOLID Principles
SOLID Principles
 
Solid principles
Solid principlesSolid principles
Solid principles
 
Open Closed Principle kata
Open Closed Principle kataOpen Closed Principle kata
Open Closed Principle kata
 
SOLID PRINCIPLES
SOLID PRINCIPLESSOLID PRINCIPLES
SOLID PRINCIPLES
 
Clean code: SOLID (iOS)
Clean code: SOLID (iOS)Clean code: SOLID (iOS)
Clean code: SOLID (iOS)
 
Solid principles
Solid principlesSolid principles
Solid principles
 
Clean Architecture
Clean ArchitectureClean Architecture
Clean Architecture
 
Solid design principles
Solid design principlesSolid design principles
Solid design principles
 

Ähnlich wie Solid Principle

The OO Design Principles
The OO Design PrinciplesThe OO Design Principles
The OO Design PrinciplesSteve Zhang
 
SOLID principles-Present
SOLID principles-PresentSOLID principles-Present
SOLID principles-PresentQuang Nguyen
 
Geecon09: SOLID Design Principles
Geecon09: SOLID Design PrinciplesGeecon09: SOLID Design Principles
Geecon09: SOLID Design PrinciplesBruno Bossola
 
SOLID design principles in Ruby
SOLID design principles in RubySOLID design principles in Ruby
SOLID design principles in RubyAnil Wadghule
 
Pavlo Zhdanov "Mastering solid and base principles for software design"
Pavlo Zhdanov "Mastering solid and base principles for software design"Pavlo Zhdanov "Mastering solid and base principles for software design"
Pavlo Zhdanov "Mastering solid and base principles for software design"LogeekNightUkraine
 
Solid OO & Clean Coding is essential to successful Agile development
Solid OO & Clean Coding is essential to successful Agile developmentSolid OO & Clean Coding is essential to successful Agile development
Solid OO & Clean Coding is essential to successful Agile developmentSimon Gould
 
Software Design Principles
Software Design PrinciplesSoftware Design Principles
Software Design PrinciplesOcean Dong
 
DesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatternsDesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatternsBasavaraj Patil
 
OO design principles & heuristics
OO design principles & heuristicsOO design principles & heuristics
OO design principles & heuristicsDhaval Shah
 
Object Oriented Design SOLID Principles
Object Oriented Design SOLID PrinciplesObject Oriented Design SOLID Principles
Object Oriented Design SOLID Principlesrainynovember12
 
Programming for a better world
Programming for a better worldProgramming for a better world
Programming for a better worldjhansi reddy
 
Object Oriented Design Principles
Object Oriented Design PrinciplesObject Oriented Design Principles
Object Oriented Design PrinciplesThang Tran Duc
 
Are You a SOLID Coder?
Are You a SOLID Coder?Are You a SOLID Coder?
Are You a SOLID Coder?Steve Green
 
Solid principles of oo design
Solid principles of oo designSolid principles of oo design
Solid principles of oo designConfiz
 
Software design principles
Software design principlesSoftware design principles
Software design principlesMd.Mojibul Hoque
 
Common Design Patterns.pptx
Common Design Patterns.pptxCommon Design Patterns.pptx
Common Design Patterns.pptxfake195786
 
Is your code solid
Is your code solidIs your code solid
Is your code solidNathan Gloyn
 
Episode 21 - Design Pattern 1
Episode 21 - Design Pattern 1Episode 21 - Design Pattern 1
Episode 21 - Design Pattern 1Jitendra Zaa
 
Object-oriented design principles
Object-oriented design principlesObject-oriented design principles
Object-oriented design principlesXiaoyan Chen
 

Ähnlich wie Solid Principle (20)

The OO Design Principles
The OO Design PrinciplesThe OO Design Principles
The OO Design Principles
 
SOLID principles-Present
SOLID principles-PresentSOLID principles-Present
SOLID principles-Present
 
Geecon09: SOLID Design Principles
Geecon09: SOLID Design PrinciplesGeecon09: SOLID Design Principles
Geecon09: SOLID Design Principles
 
SOLID design principles in Ruby
SOLID design principles in RubySOLID design principles in Ruby
SOLID design principles in Ruby
 
Pavlo Zhdanov "Mastering solid and base principles for software design"
Pavlo Zhdanov "Mastering solid and base principles for software design"Pavlo Zhdanov "Mastering solid and base principles for software design"
Pavlo Zhdanov "Mastering solid and base principles for software design"
 
Solid OO & Clean Coding is essential to successful Agile development
Solid OO & Clean Coding is essential to successful Agile developmentSolid OO & Clean Coding is essential to successful Agile development
Solid OO & Clean Coding is essential to successful Agile development
 
Software Design Principles
Software Design PrinciplesSoftware Design Principles
Software Design Principles
 
DesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatternsDesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatterns
 
OO design principles & heuristics
OO design principles & heuristicsOO design principles & heuristics
OO design principles & heuristics
 
Object Oriented Design SOLID Principles
Object Oriented Design SOLID PrinciplesObject Oriented Design SOLID Principles
Object Oriented Design SOLID Principles
 
OO Design Principles
OO Design PrinciplesOO Design Principles
OO Design Principles
 
Programming for a better world
Programming for a better worldProgramming for a better world
Programming for a better world
 
Object Oriented Design Principles
Object Oriented Design PrinciplesObject Oriented Design Principles
Object Oriented Design Principles
 
Are You a SOLID Coder?
Are You a SOLID Coder?Are You a SOLID Coder?
Are You a SOLID Coder?
 
Solid principles of oo design
Solid principles of oo designSolid principles of oo design
Solid principles of oo design
 
Software design principles
Software design principlesSoftware design principles
Software design principles
 
Common Design Patterns.pptx
Common Design Patterns.pptxCommon Design Patterns.pptx
Common Design Patterns.pptx
 
Is your code solid
Is your code solidIs your code solid
Is your code solid
 
Episode 21 - Design Pattern 1
Episode 21 - Design Pattern 1Episode 21 - Design Pattern 1
Episode 21 - Design Pattern 1
 
Object-oriented design principles
Object-oriented design principlesObject-oriented design principles
Object-oriented design principles
 

KĂŒrzlich hochgeladen

RT Nagar Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...
RT Nagar Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...RT Nagar Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...
RT Nagar Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...amitlee9823
 
VIP Model Call Girls Kalyani Nagar ( Pune ) Call ON 8005736733 Starting From ...
VIP Model Call Girls Kalyani Nagar ( Pune ) Call ON 8005736733 Starting From ...VIP Model Call Girls Kalyani Nagar ( Pune ) Call ON 8005736733 Starting From ...
VIP Model Call Girls Kalyani Nagar ( Pune ) Call ON 8005736733 Starting From ...SUHANI PANDEY
 
VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...
VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...
VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...Call Girls in Nagpur High Profile
 
Tapestry Clothing Brands: Collapsing the Funnel
Tapestry Clothing Brands: Collapsing the FunnelTapestry Clothing Brands: Collapsing the Funnel
Tapestry Clothing Brands: Collapsing the Funneljen_giacalone
 
Stark Industries Marketing Plan (1).pptx
Stark Industries Marketing Plan (1).pptxStark Industries Marketing Plan (1).pptx
Stark Industries Marketing Plan (1).pptxjeswinjees
 
CALL ON ➄8923113531 🔝Call Girls Aminabad Lucknow best Night Fun service
CALL ON ➄8923113531 🔝Call Girls Aminabad Lucknow best Night Fun serviceCALL ON ➄8923113531 🔝Call Girls Aminabad Lucknow best Night Fun service
CALL ON ➄8923113531 🔝Call Girls Aminabad Lucknow best Night Fun serviceanilsa9823
 
CALL ON ➄8923113531 🔝Call Girls Kalyanpur Lucknow best Female service đŸ§”
CALL ON ➄8923113531 🔝Call Girls Kalyanpur Lucknow best Female service  đŸ§”CALL ON ➄8923113531 🔝Call Girls Kalyanpur Lucknow best Female service  đŸ§”
CALL ON ➄8923113531 🔝Call Girls Kalyanpur Lucknow best Female service đŸ§”anilsa9823
 
The_Canvas_of_Creative_Mastery_Newsletter_April_2024_Version.pdf
The_Canvas_of_Creative_Mastery_Newsletter_April_2024_Version.pdfThe_Canvas_of_Creative_Mastery_Newsletter_April_2024_Version.pdf
The_Canvas_of_Creative_Mastery_Newsletter_April_2024_Version.pdfAmirYakdi
 
DragonBall PowerPoint Template for demo.pptx
DragonBall PowerPoint Template for demo.pptxDragonBall PowerPoint Template for demo.pptx
DragonBall PowerPoint Template for demo.pptxmirandajeremy200221
 
Top Rated Pune Call Girls Koregaon Park ⟟ 6297143586 ⟟ Call Me For Genuine S...
Top Rated  Pune Call Girls Koregaon Park ⟟ 6297143586 ⟟ Call Me For Genuine S...Top Rated  Pune Call Girls Koregaon Park ⟟ 6297143586 ⟟ Call Me For Genuine S...
Top Rated Pune Call Girls Koregaon Park ⟟ 6297143586 ⟟ Call Me For Genuine S...Call Girls in Nagpur High Profile
 
Verified Trusted Call Girls Adugodi💘 9352852248 Good Looking standard Profil...
Verified Trusted Call Girls Adugodi💘 9352852248  Good Looking standard Profil...Verified Trusted Call Girls Adugodi💘 9352852248  Good Looking standard Profil...
Verified Trusted Call Girls Adugodi💘 9352852248 Good Looking standard Profil...kumaririma588
 
Booking open Available Pune Call Girls Kirkatwadi 6297143586 Call Hot Indian...
Booking open Available Pune Call Girls Kirkatwadi  6297143586 Call Hot Indian...Booking open Available Pune Call Girls Kirkatwadi  6297143586 Call Hot Indian...
Booking open Available Pune Call Girls Kirkatwadi 6297143586 Call Hot Indian...Call Girls in Nagpur High Profile
 
Booking open Available Pune Call Girls Nanded City 6297143586 Call Hot India...
Booking open Available Pune Call Girls Nanded City  6297143586 Call Hot India...Booking open Available Pune Call Girls Nanded City  6297143586 Call Hot India...
Booking open Available Pune Call Girls Nanded City 6297143586 Call Hot India...Call Girls in Nagpur High Profile
 
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Gi...
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Gi...Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Gi...
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Gi...Pooja Nehwal
 
VVIP CALL GIRLS Lucknow 💓 Lucknow < Renuka Sharma > 7877925207 Escorts Service
VVIP CALL GIRLS Lucknow 💓 Lucknow < Renuka Sharma > 7877925207 Escorts ServiceVVIP CALL GIRLS Lucknow 💓 Lucknow < Renuka Sharma > 7877925207 Escorts Service
VVIP CALL GIRLS Lucknow 💓 Lucknow < Renuka Sharma > 7877925207 Escorts Servicearoranaina404
 
The history of music videos a level presentation
The history of music videos a level presentationThe history of music videos a level presentation
The history of music videos a level presentationamedia6
 
Jigani Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...
Jigani Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...Jigani Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...
Jigani Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...amitlee9823
 
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Hy...
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Hy...Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Hy...
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Hy...Pooja Nehwal
 
AMBER GRAIN EMBROIDERY | Growing folklore elements | Root-based materials, w...
AMBER GRAIN EMBROIDERY | Growing folklore elements |  Root-based materials, w...AMBER GRAIN EMBROIDERY | Growing folklore elements |  Root-based materials, w...
AMBER GRAIN EMBROIDERY | Growing folklore elements | Root-based materials, w...BarusRa
 

KĂŒrzlich hochgeladen (20)

RT Nagar Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...
RT Nagar Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...RT Nagar Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...
RT Nagar Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...
 
Call Girls Service Mukherjee Nagar @9999965857 Delhi đŸ«Š No Advance VVIP 🍎 SER...
Call Girls Service Mukherjee Nagar @9999965857 Delhi đŸ«Š No Advance  VVIP 🍎 SER...Call Girls Service Mukherjee Nagar @9999965857 Delhi đŸ«Š No Advance  VVIP 🍎 SER...
Call Girls Service Mukherjee Nagar @9999965857 Delhi đŸ«Š No Advance VVIP 🍎 SER...
 
VIP Model Call Girls Kalyani Nagar ( Pune ) Call ON 8005736733 Starting From ...
VIP Model Call Girls Kalyani Nagar ( Pune ) Call ON 8005736733 Starting From ...VIP Model Call Girls Kalyani Nagar ( Pune ) Call ON 8005736733 Starting From ...
VIP Model Call Girls Kalyani Nagar ( Pune ) Call ON 8005736733 Starting From ...
 
VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...
VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...
VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...
 
Tapestry Clothing Brands: Collapsing the Funnel
Tapestry Clothing Brands: Collapsing the FunnelTapestry Clothing Brands: Collapsing the Funnel
Tapestry Clothing Brands: Collapsing the Funnel
 
Stark Industries Marketing Plan (1).pptx
Stark Industries Marketing Plan (1).pptxStark Industries Marketing Plan (1).pptx
Stark Industries Marketing Plan (1).pptx
 
CALL ON ➄8923113531 🔝Call Girls Aminabad Lucknow best Night Fun service
CALL ON ➄8923113531 🔝Call Girls Aminabad Lucknow best Night Fun serviceCALL ON ➄8923113531 🔝Call Girls Aminabad Lucknow best Night Fun service
CALL ON ➄8923113531 🔝Call Girls Aminabad Lucknow best Night Fun service
 
CALL ON ➄8923113531 🔝Call Girls Kalyanpur Lucknow best Female service đŸ§”
CALL ON ➄8923113531 🔝Call Girls Kalyanpur Lucknow best Female service  đŸ§”CALL ON ➄8923113531 🔝Call Girls Kalyanpur Lucknow best Female service  đŸ§”
CALL ON ➄8923113531 🔝Call Girls Kalyanpur Lucknow best Female service đŸ§”
 
The_Canvas_of_Creative_Mastery_Newsletter_April_2024_Version.pdf
The_Canvas_of_Creative_Mastery_Newsletter_April_2024_Version.pdfThe_Canvas_of_Creative_Mastery_Newsletter_April_2024_Version.pdf
The_Canvas_of_Creative_Mastery_Newsletter_April_2024_Version.pdf
 
DragonBall PowerPoint Template for demo.pptx
DragonBall PowerPoint Template for demo.pptxDragonBall PowerPoint Template for demo.pptx
DragonBall PowerPoint Template for demo.pptx
 
Top Rated Pune Call Girls Koregaon Park ⟟ 6297143586 ⟟ Call Me For Genuine S...
Top Rated  Pune Call Girls Koregaon Park ⟟ 6297143586 ⟟ Call Me For Genuine S...Top Rated  Pune Call Girls Koregaon Park ⟟ 6297143586 ⟟ Call Me For Genuine S...
Top Rated Pune Call Girls Koregaon Park ⟟ 6297143586 ⟟ Call Me For Genuine S...
 
Verified Trusted Call Girls Adugodi💘 9352852248 Good Looking standard Profil...
Verified Trusted Call Girls Adugodi💘 9352852248  Good Looking standard Profil...Verified Trusted Call Girls Adugodi💘 9352852248  Good Looking standard Profil...
Verified Trusted Call Girls Adugodi💘 9352852248 Good Looking standard Profil...
 
Booking open Available Pune Call Girls Kirkatwadi 6297143586 Call Hot Indian...
Booking open Available Pune Call Girls Kirkatwadi  6297143586 Call Hot Indian...Booking open Available Pune Call Girls Kirkatwadi  6297143586 Call Hot Indian...
Booking open Available Pune Call Girls Kirkatwadi 6297143586 Call Hot Indian...
 
Booking open Available Pune Call Girls Nanded City 6297143586 Call Hot India...
Booking open Available Pune Call Girls Nanded City  6297143586 Call Hot India...Booking open Available Pune Call Girls Nanded City  6297143586 Call Hot India...
Booking open Available Pune Call Girls Nanded City 6297143586 Call Hot India...
 
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Gi...
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Gi...Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Gi...
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Gi...
 
VVIP CALL GIRLS Lucknow 💓 Lucknow < Renuka Sharma > 7877925207 Escorts Service
VVIP CALL GIRLS Lucknow 💓 Lucknow < Renuka Sharma > 7877925207 Escorts ServiceVVIP CALL GIRLS Lucknow 💓 Lucknow < Renuka Sharma > 7877925207 Escorts Service
VVIP CALL GIRLS Lucknow 💓 Lucknow < Renuka Sharma > 7877925207 Escorts Service
 
The history of music videos a level presentation
The history of music videos a level presentationThe history of music videos a level presentation
The history of music videos a level presentation
 
Jigani Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...
Jigani Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...Jigani Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...
Jigani Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...
 
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Hy...
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Hy...Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Hy...
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Hy...
 
AMBER GRAIN EMBROIDERY | Growing folklore elements | Root-based materials, w...
AMBER GRAIN EMBROIDERY | Growing folklore elements |  Root-based materials, w...AMBER GRAIN EMBROIDERY | Growing folklore elements |  Root-based materials, w...
AMBER GRAIN EMBROIDERY | Growing folklore elements | Root-based materials, w...
 

Solid Principle

  • 1. The OO Design PrinciplesThe OO Design Principles
  • 2. Agenda Need of Design Design Smells 2 Class Design Principles Summary
  • 3. Agenda Need of Design Design Smells 3 Class Design Principles Summary
  • 4. What's meaning of design..? What's the different compared to Design is about how What Design Exactly About is..? 4 compared to analysis..? Analysis is about what
  • 5. Why do we Need Design..? To deliver faster To manage change Why do we need design..? 5 change To deal with complexity
  • 6. Agenda Need of Design Design Smells 6 Class Design Principles Summary
  • 7. Okay... I under stand the Importance of design How do we know a Design is bad..? Design Smells 7 Are they any symptoms Of bad design...
  • 9. Rigidity Tendency for software to be difficult to change. The design is hard to change 9 Tendency for software to be difficult to change. Single change causes cascade of subsequent changes in dependent modules. The more module must be changed the more rigid the design.
  • 10. Fragility Tendency of the software to break in many places every The design is easy to break 10 Tendency of the software to break in many places every time it's changed . The breakage occurs in areas with no conceptual relationship On every fix the software breaks in unexpected way.
  • 11. Immobility Inability to reuse software from other projects or modules . Difficult to reuse 11 Inability to reuse software from other projects or modules . The useful module have to many dependencies. Cost of rewriting is less compared to the risk faced to separate those part.
  • 12. Viscosity It's easy to do the wrong thing, but hard to do the right Hard to do the right thing 12 It's easy to do the wrong thing, but hard to do the right thing. When the design preserving methods are more difficult to use then the hacks When dev environment is slow and inefficient developer will be tempted to do wrong things.
  • 13. Why design becomes rigid, Fragile Immobile and viscousIs there any Characteristics For good design Design Characteristics 13
  • 15. So how can we Achieve good Design..? SRP LSP OCP Design Characteristics 15 ISP DIP So let's go SOLID..
  • 16. Single Responsibility Principle There should never be more then one reason This is hard to see, as we think Responsibility in group 16 There should never be more then one reason to change a class. Many responsibility means many reason to change.
  • 17. 1. Removes the immobility Smell from Design. 2. Deodorizes the Rigidity Smell Ohh.. SRP Benefits of SRP 17
  • 18. Open Closed Principle Software entities should be open for extension, but closed for Abstraction is the key 18 Software entities should be open for extension, but closed for modification. Keep the things that change frequently away from things that don't change.
  • 19. Open Closed Principle (contd
) Open for Extension Behavior of the module can be extended. Closed for Modification The source of such a module is invisible. OCP is the heart of object oriented design 19 Make the module behave in new and different ways as the requirement of the application change. Resist making source change to it.
  • 20. Is 100% Closer possible Is there any techniques In Reality 100% Closer is not attainable. Closer must be Strategic. Abstraction is the key Further thinking of OCP 20 Flexibility, re usability and maintainability is The benefits
  • 21. Liskov's SubstitutionPrinciple LSP defines the inheritance principle. Subclass should be substitutable for their base class 21 LSP defines the inheritance principle. It makes clear that in OO design IS-A relationship is about behavior; behavior that clients depend on. If client uses a base class, then it should not differentiate the base class.
  • 22. LSP Violation Example void g(Rectangle r) { r.setWidth(5); r.setHeight(4); if(r.getArea() != 20) throw new Exception("Bad area!"); Square is not Rectangle! 22 Exception("Bad area!"); } IS-A Relationship Square’s behavior is changed, so it is not substitutable to Rectangle
  • 23. Further thinking of LSP In order to be substitutable, the contract of the base class must be honored by the derived class. Derived class substitutable or base class, if Design by Contract 23 Derived class substitutable or base class, if Preconditions are no stronger then the base class Preconditions are no weaker then the base class Derived method should expect no more and provide no less
  • 24. LSP Violation The solution will likely to be put into an if else statement in the client side. Are you sure it works? What happen if new derivatives of rectangle come..? May be we've allocate 24 May be we've allocate The responsibility Wrongly. It violates OCP
  • 25. Interface Segregation Principle Client should not forced to depend on methods they do not Many client specific interface are Better then one general purpose interface 25 Client should not forced to depend on methods they do not use. ISP deals with designing cohesive interfaces and avoiding fat interfaces. What happen when the big class changes? All depending module must also change.
  • 26. Service <<Client A methods>> + ... <<Client B methods>> + ... <<Client C methods>> + ... Client A Client B An violation of ISP example 26 ISP violation Client C
  • 27. Segregated interface Service <<Interface>> Service A <<Client A methods>> + .. <<Interface>> Service B Client A An violation of ISP example: Solution 27 <<Client A methods>> + ... <<Client B methods>> + ... <<Client C methods>> + ... Service B <<Client B methods>> + .. <<Interface>> Service C <<Client C methods>> + .. Client B Client C
  • 28. Dependency Inversion Principle High level module should not depend upon low level Depend upon abstraction. Do not depend Upon concretions 28 High level module should not depend upon low level modules, both should depends upon abstraction Abstraction should not depends upon on details, details should depends on abstraction.
  • 30. DIP Summary Inversion of dependencies is the hallmark of good object oriented design. If it's dependencies are inverted, it has an OO design If it's dependencies are not inverted it has a procedural design. Dependency injection is the core of the famous spring 30 Dependency injection is the core of the famous spring framework Hollywood principle: “ Don't call us, we'll call you”.
  • 31. Summary ‱ A class should have only one reason to changeSRP ‱ A Module should be open for extension but closed for modification.OCP ‱ Subclass should be substitutable for their base LSP 31 ‱ Subclass should be substitutable for their base class.LSP ‱ Many client specific interfaces are better then one general purpose interface .ISP ‱ Depends upon abstraction. Do not depends upon concretions.DIP