SlideShare ist ein Scribd-Unternehmen logo
1 von 23
SOLID
HADI EHTERAMI
AUGUST 2020
The reason behind most unsuccessful
applications
 Putting more stress on classes by assigning more responsibilities to them. (A lot of
functionality not related to a class.)
 Forcing the classes to depend on each other. If classes are dependent on each
other (in other words tightly coupled), then a change in one will affect the other.
 Spreading duplicate code in the system/application.
Solution
 Choosing the correct architecture (in other words MVC, micro service ,3-tier,
Layered, MVP, MVVP and so on).
 Following Design Principles.
 Choosing correct Design Patterns to build the software based on its
specifications.
What is SOLID?
History
 The term SOLID is an acronym for five design principles intended to make
software designs more understandable, flexible and maintainable.
 The principles are a subset of many principles promoted by Robert C. Martin
 The SOLID acronym was first introduced by Michael Feathers.
S — Single responsibility principle
 "Every software module should have only one reason to
change“
 This means that every class, or similar structure, in your
code should have only one job to do. Everything in that
class should be related to a single purpose.
 Small is good 
Problem?
Solve
O — Open/closed principle
 The Open/closed Principle says "A software module/class is
open for extension and closed for modification“
 "Open for extension" means, we need to design our
module/class in such a way that the new functionality can be
added only when new requirements are generated.
 "Closed for modification" means we have already developed
a class and it has gone through unit testing. We should then
not alter it until we find bugs. As it says, a class should be
open for extensions, we can use inheritance to do this.
Problem
1
2
Now we want calculate Circle Area!
How?
L — Liskov substitution principle
 "you should be able to use any derived class instead of
a parent class and have it behave in the same manner
without modification“
 This principle is just an extension of the Open Close
Principle and it means that we must ensure that new
derived classes extend the base classes without changing
their behavior.
LSP Code Example
I — Interface segregation principle
 "that clients should not be forced to implement
interfaces they don't use. Instead of one fat interface
many small interfaces are preferred based on groups of
methods, each one serving one sub module.“
 Do not add additional functionality to an existing
interface by adding new methods.
Instead, create a new interface and let your class
implement multiple interfaces if needed.
Problem
Solve
Continue
D: Dependency Inversion Principle
 The Dependency Inversion Principle (DIP) states that high-level
modules/classes should not depend on low-level modules/classes.
Both should depend upon abstractions
 Secondly, abstractions should not depend upon details. Details
should depend upon abstractions.
 is a way to decouple software modules.
 dependency inversion pattern, most often solved by using
dependency injection.
 Adapter Design Pattern use DIP
DI Sample
If don’t use SOLID Principles
 End up with strong coupling of the code with other modules
 End up with a code which is not testable
 End up with duplication of code
 Fix a bug with create another bug 
Following SOLID Principles …
 Achieve reduction in complicity of code
 Increase readability, extensibility and maintenance
 Reduce error and implement Reusability
 Achieve better testability
 Reduce tight coupling
Conclusion
 These are 5 essential principles used by professional software engineers all around the
globe, and if you are serious about creating ‘solid’ software, you should start applying
these principles today!

Weitere ähnliche Inhalte

Was ist angesagt?

Software design principles
Software design principlesSoftware design principles
Software design principlesMd.Mojibul Hoque
 
Software Design Principles
Software Design PrinciplesSoftware Design Principles
Software Design PrinciplesOcean Dong
 
Can't Handle My Scale v2
Can't Handle My Scale v2Can't Handle My Scale v2
Can't Handle My Scale v2Michele Titolo
 
The Open Closed Principle - Part 1 - The Original Version
The Open Closed Principle - Part 1 - The Original VersionThe Open Closed Principle - Part 1 - The Original Version
The Open Closed Principle - Part 1 - The Original VersionPhilip Schwarz
 
CS519 - project idea presentation
CS519 - project idea presentationCS519 - project idea presentation
CS519 - project idea presentationSergii Shmarkatiuk
 
Scrum Antipatterns And the Power of combining Scrum & XP
Scrum Antipatterns And the Power of combining Scrum & XPScrum Antipatterns And the Power of combining Scrum & XP
Scrum Antipatterns And the Power of combining Scrum & XPMonica Gupta
 
Daniel leon design principles in the functional world
Daniel leon   design principles in the functional worldDaniel leon   design principles in the functional world
Daniel leon design principles in the functional worldCodecamp Romania
 

Was ist angesagt? (12)

Design patterns
Design patternsDesign patterns
Design patterns
 
Solid principles
Solid principlesSolid principles
Solid principles
 
Software design principles
Software design principlesSoftware design principles
Software design principles
 
Solid principles
Solid principlesSolid principles
Solid principles
 
Software Design Principles
Software Design PrinciplesSoftware Design Principles
Software Design Principles
 
Can't Handle My Scale v2
Can't Handle My Scale v2Can't Handle My Scale v2
Can't Handle My Scale v2
 
The Open Closed Principle - Part 1 - The Original Version
The Open Closed Principle - Part 1 - The Original VersionThe Open Closed Principle - Part 1 - The Original Version
The Open Closed Principle - Part 1 - The Original Version
 
Css 422 week 4 d qs and summary
Css 422 week 4 d qs and summaryCss 422 week 4 d qs and summary
Css 422 week 4 d qs and summary
 
CS519 - project idea presentation
CS519 - project idea presentationCS519 - project idea presentation
CS519 - project idea presentation
 
Scrum Antipatterns And the Power of combining Scrum & XP
Scrum Antipatterns And the Power of combining Scrum & XPScrum Antipatterns And the Power of combining Scrum & XP
Scrum Antipatterns And the Power of combining Scrum & XP
 
Daniel leon design principles in the functional world
Daniel leon   design principles in the functional worldDaniel leon   design principles in the functional world
Daniel leon design principles in the functional world
 
When Frameworks Suck by Damnjan Jovanic
When Frameworks Suck by Damnjan JovanicWhen Frameworks Suck by Damnjan Jovanic
When Frameworks Suck by Damnjan Jovanic
 

Ähnlich wie Solid

DesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatternsDesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatternsBasavaraj Patil
 
Object Oriented Design SOLID Principles
Object Oriented Design SOLID PrinciplesObject Oriented Design SOLID Principles
Object Oriented Design SOLID Principlesrainynovember12
 
Software design principles - jinal desai
Software design principles - jinal desaiSoftware design principles - jinal desai
Software design principles - jinal desaijinaldesailive
 
S.O.L.I.D. principles of software development
S.O.L.I.D. principles of software developmentS.O.L.I.D. principles of software development
S.O.L.I.D. principles of software developmentAmanSoni129
 
Dependency Injection, Design Principles and Patterns
Dependency Injection, Design Principles and PatternsDependency Injection, Design Principles and Patterns
Dependency Injection, Design Principles and PatternsJuan Lopez
 
An ultimate guide to SOLID Principles, developers must know.
An ultimate guide to SOLID Principles, developers must know.An ultimate guide to SOLID Principles, developers must know.
An ultimate guide to SOLID Principles, developers must know.ONE BCG
 
SOLID Design Principles for Test Automaion
SOLID Design Principles for Test AutomaionSOLID Design Principles for Test Automaion
SOLID Design Principles for Test AutomaionKnoldus Inc.
 
Design Principles to design Patterns
Design Principles to design PatternsDesign Principles to design Patterns
Design Principles to design PatternsFaizan Haider
 
Design principle vs design patterns
Design principle vs design patternsDesign principle vs design patterns
Design principle vs design patternsPrabhakar Sharma
 
Solid design principles
Solid design principlesSolid design principles
Solid design principlesMahmoud Asadi
 
Practical Enterprise Application Development
Practical Enterprise Application DevelopmentPractical Enterprise Application Development
Practical Enterprise Application DevelopmentAdil Mughal
 
Inversion of Control
Inversion of ControlInversion of Control
Inversion of ControlShuhab Tariq
 
Are You a SOLID Coder?
Are You a SOLID Coder?Are You a SOLID Coder?
Are You a SOLID Coder?Steve Green
 
Test Driven Development:Unit Testing, Dependency Injection, Mocking
Test Driven Development:Unit Testing, Dependency Injection, MockingTest Driven Development:Unit Testing, Dependency Injection, Mocking
Test Driven Development:Unit Testing, Dependency Injection, Mockingmrjawright
 
Solid principles, Design Patterns, and Domain Driven Design
Solid principles, Design Patterns, and Domain Driven DesignSolid principles, Design Patterns, and Domain Driven Design
Solid principles, Design Patterns, and Domain Driven DesignIrwansyah Irwansyah
 
OO design principle
OO design principleOO design principle
OO design principleLi-Wei Cheng
 

Ähnlich wie Solid (20)

DesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatternsDesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatterns
 
Object Oriented Design SOLID Principles
Object Oriented Design SOLID PrinciplesObject Oriented Design SOLID Principles
Object Oriented Design SOLID Principles
 
Software design principles - jinal desai
Software design principles - jinal desaiSoftware design principles - jinal desai
Software design principles - jinal desai
 
S.O.L.I.D. principles of software development
S.O.L.I.D. principles of software developmentS.O.L.I.D. principles of software development
S.O.L.I.D. principles of software development
 
Dependency Injection, Design Principles and Patterns
Dependency Injection, Design Principles and PatternsDependency Injection, Design Principles and Patterns
Dependency Injection, Design Principles and Patterns
 
An ultimate guide to SOLID Principles, developers must know.
An ultimate guide to SOLID Principles, developers must know.An ultimate guide to SOLID Principles, developers must know.
An ultimate guide to SOLID Principles, developers must know.
 
SOLID Design Principles for Test Automaion
SOLID Design Principles for Test AutomaionSOLID Design Principles for Test Automaion
SOLID Design Principles for Test Automaion
 
Solid Principles
Solid PrinciplesSolid Principles
Solid Principles
 
Design Principles to design Patterns
Design Principles to design PatternsDesign Principles to design Patterns
Design Principles to design Patterns
 
Design principle vs design patterns
Design principle vs design patternsDesign principle vs design patterns
Design principle vs design patterns
 
Solid design principles
Solid design principlesSolid design principles
Solid design principles
 
android principle.pptx
android principle.pptxandroid principle.pptx
android principle.pptx
 
Practical Enterprise Application Development
Practical Enterprise Application DevelopmentPractical Enterprise Application Development
Practical Enterprise Application Development
 
OO Design Principles
OO Design PrinciplesOO Design Principles
OO Design Principles
 
Inversion of Control
Inversion of ControlInversion of Control
Inversion of Control
 
Solid principle
Solid principleSolid principle
Solid principle
 
Are You a SOLID Coder?
Are You a SOLID Coder?Are You a SOLID Coder?
Are You a SOLID Coder?
 
Test Driven Development:Unit Testing, Dependency Injection, Mocking
Test Driven Development:Unit Testing, Dependency Injection, MockingTest Driven Development:Unit Testing, Dependency Injection, Mocking
Test Driven Development:Unit Testing, Dependency Injection, Mocking
 
Solid principles, Design Patterns, and Domain Driven Design
Solid principles, Design Patterns, and Domain Driven DesignSolid principles, Design Patterns, and Domain Driven Design
Solid principles, Design Patterns, and Domain Driven Design
 
OO design principle
OO design principleOO design principle
OO design principle
 

Kürzlich hochgeladen

Mercer Global Talent Trends 2024 - Human Resources
Mercer Global Talent Trends 2024 - Human ResourcesMercer Global Talent Trends 2024 - Human Resources
Mercer Global Talent Trends 2024 - Human Resourcesmnavarrete3
 
2k Shots ≽ 9205541914 ≼ Call Girls In Vinod Nagar East (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Vinod Nagar East (Delhi)2k Shots ≽ 9205541914 ≼ Call Girls In Vinod Nagar East (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Vinod Nagar East (Delhi)Delhi Call girls
 
Arjan Call Girl Service #$# O56521286O $#$ Call Girls In Arjan
Arjan Call Girl Service #$# O56521286O $#$ Call Girls In ArjanArjan Call Girl Service #$# O56521286O $#$ Call Girls In Arjan
Arjan Call Girl Service #$# O56521286O $#$ Call Girls In Arjanparisharma5056
 
Mastering Vendor Selection and Partnership Management
Mastering Vendor Selection and Partnership ManagementMastering Vendor Selection and Partnership Management
Mastering Vendor Selection and Partnership ManagementBoundless HQ
 
RecruZone - Your Recruiting Bounty marketplace
RecruZone - Your Recruiting Bounty marketplaceRecruZone - Your Recruiting Bounty marketplace
RecruZone - Your Recruiting Bounty marketplaceDavide Donghi
 
Cleared Job Fair Handbook | May 2, 2024
Cleared Job Fair Handbook  |  May 2, 2024Cleared Job Fair Handbook  |  May 2, 2024
Cleared Job Fair Handbook | May 2, 2024ClearedJobs.Net
 
100%Safe delivery(+971558539980)Abortion pills for sale..dubai sharjah, abu d...
100%Safe delivery(+971558539980)Abortion pills for sale..dubai sharjah, abu d...100%Safe delivery(+971558539980)Abortion pills for sale..dubai sharjah, abu d...
100%Safe delivery(+971558539980)Abortion pills for sale..dubai sharjah, abu d...hyt3577
 
Webinar - How to set pay ranges in the context of pay transparency legislation
Webinar - How to set pay ranges in the context of pay transparency legislationWebinar - How to set pay ranges in the context of pay transparency legislation
Webinar - How to set pay ranges in the context of pay transparency legislationPayScale, Inc.
 
Will Robots Steal Your Jobs? Will Robots Steal Your Jobs? 10 Eye-Opening Work...
Will Robots Steal Your Jobs? Will Robots Steal Your Jobs? 10 Eye-Opening Work...Will Robots Steal Your Jobs? Will Robots Steal Your Jobs? 10 Eye-Opening Work...
Will Robots Steal Your Jobs? Will Robots Steal Your Jobs? 10 Eye-Opening Work...Jasper Colin
 
Perry Lieber Your Trusted Guide in the Dynamic World of Real Estate Investments
Perry Lieber Your Trusted Guide in the Dynamic World of Real Estate InvestmentsPerry Lieber Your Trusted Guide in the Dynamic World of Real Estate Investments
Perry Lieber Your Trusted Guide in the Dynamic World of Real Estate InvestmentsPerry Lieber
 

Kürzlich hochgeladen (10)

Mercer Global Talent Trends 2024 - Human Resources
Mercer Global Talent Trends 2024 - Human ResourcesMercer Global Talent Trends 2024 - Human Resources
Mercer Global Talent Trends 2024 - Human Resources
 
2k Shots ≽ 9205541914 ≼ Call Girls In Vinod Nagar East (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Vinod Nagar East (Delhi)2k Shots ≽ 9205541914 ≼ Call Girls In Vinod Nagar East (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Vinod Nagar East (Delhi)
 
Arjan Call Girl Service #$# O56521286O $#$ Call Girls In Arjan
Arjan Call Girl Service #$# O56521286O $#$ Call Girls In ArjanArjan Call Girl Service #$# O56521286O $#$ Call Girls In Arjan
Arjan Call Girl Service #$# O56521286O $#$ Call Girls In Arjan
 
Mastering Vendor Selection and Partnership Management
Mastering Vendor Selection and Partnership ManagementMastering Vendor Selection and Partnership Management
Mastering Vendor Selection and Partnership Management
 
RecruZone - Your Recruiting Bounty marketplace
RecruZone - Your Recruiting Bounty marketplaceRecruZone - Your Recruiting Bounty marketplace
RecruZone - Your Recruiting Bounty marketplace
 
Cleared Job Fair Handbook | May 2, 2024
Cleared Job Fair Handbook  |  May 2, 2024Cleared Job Fair Handbook  |  May 2, 2024
Cleared Job Fair Handbook | May 2, 2024
 
100%Safe delivery(+971558539980)Abortion pills for sale..dubai sharjah, abu d...
100%Safe delivery(+971558539980)Abortion pills for sale..dubai sharjah, abu d...100%Safe delivery(+971558539980)Abortion pills for sale..dubai sharjah, abu d...
100%Safe delivery(+971558539980)Abortion pills for sale..dubai sharjah, abu d...
 
Webinar - How to set pay ranges in the context of pay transparency legislation
Webinar - How to set pay ranges in the context of pay transparency legislationWebinar - How to set pay ranges in the context of pay transparency legislation
Webinar - How to set pay ranges in the context of pay transparency legislation
 
Will Robots Steal Your Jobs? Will Robots Steal Your Jobs? 10 Eye-Opening Work...
Will Robots Steal Your Jobs? Will Robots Steal Your Jobs? 10 Eye-Opening Work...Will Robots Steal Your Jobs? Will Robots Steal Your Jobs? 10 Eye-Opening Work...
Will Robots Steal Your Jobs? Will Robots Steal Your Jobs? 10 Eye-Opening Work...
 
Perry Lieber Your Trusted Guide in the Dynamic World of Real Estate Investments
Perry Lieber Your Trusted Guide in the Dynamic World of Real Estate InvestmentsPerry Lieber Your Trusted Guide in the Dynamic World of Real Estate Investments
Perry Lieber Your Trusted Guide in the Dynamic World of Real Estate Investments
 

Solid

  • 2. The reason behind most unsuccessful applications  Putting more stress on classes by assigning more responsibilities to them. (A lot of functionality not related to a class.)  Forcing the classes to depend on each other. If classes are dependent on each other (in other words tightly coupled), then a change in one will affect the other.  Spreading duplicate code in the system/application.
  • 3. Solution  Choosing the correct architecture (in other words MVC, micro service ,3-tier, Layered, MVP, MVVP and so on).  Following Design Principles.  Choosing correct Design Patterns to build the software based on its specifications.
  • 5. History  The term SOLID is an acronym for five design principles intended to make software designs more understandable, flexible and maintainable.  The principles are a subset of many principles promoted by Robert C. Martin  The SOLID acronym was first introduced by Michael Feathers.
  • 6. S — Single responsibility principle  "Every software module should have only one reason to change“  This means that every class, or similar structure, in your code should have only one job to do. Everything in that class should be related to a single purpose.  Small is good 
  • 9. O — Open/closed principle  The Open/closed Principle says "A software module/class is open for extension and closed for modification“  "Open for extension" means, we need to design our module/class in such a way that the new functionality can be added only when new requirements are generated.  "Closed for modification" means we have already developed a class and it has gone through unit testing. We should then not alter it until we find bugs. As it says, a class should be open for extensions, we can use inheritance to do this.
  • 11. Now we want calculate Circle Area!
  • 12. How?
  • 13. L — Liskov substitution principle  "you should be able to use any derived class instead of a parent class and have it behave in the same manner without modification“  This principle is just an extension of the Open Close Principle and it means that we must ensure that new derived classes extend the base classes without changing their behavior.
  • 15. I — Interface segregation principle  "that clients should not be forced to implement interfaces they don't use. Instead of one fat interface many small interfaces are preferred based on groups of methods, each one serving one sub module.“  Do not add additional functionality to an existing interface by adding new methods. Instead, create a new interface and let your class implement multiple interfaces if needed.
  • 17. Solve
  • 19. D: Dependency Inversion Principle  The Dependency Inversion Principle (DIP) states that high-level modules/classes should not depend on low-level modules/classes. Both should depend upon abstractions  Secondly, abstractions should not depend upon details. Details should depend upon abstractions.  is a way to decouple software modules.  dependency inversion pattern, most often solved by using dependency injection.  Adapter Design Pattern use DIP
  • 21. If don’t use SOLID Principles  End up with strong coupling of the code with other modules  End up with a code which is not testable  End up with duplication of code  Fix a bug with create another bug 
  • 22. Following SOLID Principles …  Achieve reduction in complicity of code  Increase readability, extensibility and maintenance  Reduce error and implement Reusability  Achieve better testability  Reduce tight coupling
  • 23. Conclusion  These are 5 essential principles used by professional software engineers all around the globe, and if you are serious about creating ‘solid’ software, you should start applying these principles today!