SlideShare a Scribd company logo
1 of 63
SOLID DESIGN
PRINCIPLES
Avidnyat Chiddarwar
Senior Technical Lead
Design Principles!!!!
Software design principles represent a set of
guidelines that helps us to avoid having a
bad design.
“
● Rigidity - It is hard to change because every
change affects too many other parts of the
system.
● Fragility - When you make a change, unexpected
parts of the system break.
● Immobility - It is hard to reuse in another
application because it cannot be disentangled
from the current application.
Characteristics of bad design
Design Principles
Open Close Principle
Interface Segregation Principle
Single Responsibility Principle
Dependency Inversion Principle
Liskov’s Substitution Principle
1.
Single Responsibility Principle
A class should have only one reason
to change.
Single Responsibility Principle
Single Responsibility Principle
Single Responsibility Principle
There should be only one reason to change class.
If reasons are two then split the class.
To keep class more atomized as possible.
The concept could be extended to the methods of
class too, keeping easy the management of all
internal structure.
Benefits Of Single Responsibility Principle
Easier to test, read and maintain.
Less side effects.
Separation of concerns.
Naming does’nt gets tricky.
Example
Violation of SRP
3 reasons to change one class.
If one of the method breaks all modules depending on it will break.
Reading and maintaining becomes difficult.
Reusability is less.
Low cohesion, tightly coupled
If there is any new change to the class, developer has to
understand complete class all methods of that class and then can
start working on it. As well as tester has to test all methods again
instead of testing only added change.
Best example to give is fixing one bug raises 10 or more bugs
Benefits of SRP
Only 1 reason to change one class.
Reading and maintaining becomes easy.
Reusability is more.
High cohesion, loosely coupled
If there is any new change to the class, developer has to
understand only one class and methods of that class and then can
start working on it. As well as tester has to test few methods.
Attribute Of SRP - Cohesion
High cohesion.
Cohesion refers to the degree with which elements of code belong
together.
This means that the level of cohesion between elements is higher if
they are related, and lower if they are not.
Having a class with many methods that do one job means that
class has high cohesion.
Attribute Of SRP - Coupling
Low coupling.
Coupling is the manner of independence between modules of a
programming system.
This means that high coupling means that modules are more
dependent upon one another, and low coupling means they are
less dependent.
Having a class with many methods that do one job means that
that class has high cohesion.
2.
Open Closed Principle
Open for extension and closed for modification
Open Close Principle Real Example
Open for extension and close for modification
Open Close Principle
An adapter in the wall is always closed for
modification, in other words we cannot change it
once it is fitted or extended if we want more.
But an adapter always provides a method of
extension, so we can plug in an extension board of
an adapter for more adaptation.
So you plug in an extension board and extend an
existing electric adapter fitted in wall.
Open Close Principle
OPC is a generic principle. You can consider it
when writing your classes to make sure that when
you need to extend their behavior you don’t have
to change the class but to extend it.
The same principle can be applied for modules,
packages, libraries.
If you have a library containing a set of classes
there are many reasons for which you will prefer
to extend it without changing the code that was
already written.
Example
Violation of Open Close Principle
Open for modification and closed for extension
If one of the method breaks all modules depending on it will break.
Reading and maintaining becomes difficult.
Reusability is less.
If there is any new change to the class, developer has to
understand complete class all methods of that class and then can
start working on it. As well as tester has to test all methods again
instead of testing only added change.
Best example to give is fixing one bug raises 10 or more bugs
Pros of Open Close Principle
Open for extension and closed for modification
If one of the method breaks other modules still remain intact.
Reusability is high.
If there is any new change to the class, developer does not have to
understand complete class all methods of that class and then can
start working on it.
As well as tester does not have to test all methods again instead of
that has to test only one change.
Applying strategy design pattern or template design pattern helps
in solving problem.
3.
Liskov’s Substituion
Principle
Derived types must be completely substitutable
for their base types.
Liskov’s Substitution Principle
This principle is just an extension of the Open
Close Principle in terms of behavior meaning that
we must make sure that new derived classes are
extending the base classes without changing
their behavior.
The new derived classes should be able to replace
the base classes without any change in the code.
Example
Cons of Liskov’s Substitution Principle
Difficult to understand why it broked after
substitution.
Developer has to understand and remember all
derived types and extra operations that class
does.
Difficult to change client code after substitution.
4.
Interface Segregation
Principle
Clients should not be forced to depend upon
interfaces that they don't use.
Interface Segregation Principle
This principle teaches us to take care how we
write our interfaces.
When we write our interfaces we should take care
to add only methods that should be there.
If we add methods that should not be there the
classes implementing the interface will have to
implement those methods as well.
As a conclusion Interfaces containing methods
that are not specific to it are called polluted or fat
interfaces. We should avoid them.
Example
Violations of Interface Segregation Principle
If robot class does not need eat method still it is
forced to implement.
As interface is polluted for any new change
developer has to understand complete class.
Reusability with huge cost
Pros of Interface Segregation Principle
Easy to read and understand.
Loosely coupled.
Reusability with low cost.
Developer has to understand only one interface
with small unit of code.
5.
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.
Dependency Inversion Principle
Dependency Inversion Principle states that we
should decouple high level modules from low level
modules, introducing an abstraction layer
between the high level classes and low level
classes.
Dependency Inversion Principle
In the classical way when a software
module(class, framework) need some other
module, it initializes and holds a direct reference
to it. This will make the 2 modules tight coupled.
In order to decouple them the first module will
provide a hook(a property, parameter) and an
external module controlling the dependencies will
inject the reference to the second one.
Dependency Inversion Principle
When we design software applications we can consider the low
level classes the classes which implement basic and primary
operations(disk access, network protocols,...) and high level
classes the classes which encapsulate complex logic(business
flows, ...).
The last ones rely on the low level classes. A natural way of
implementing such structures would be to write low level classes
and once we have them to write the complex high level classes.
Since high level classes are defined in terms of others this seems
the logical way to do it. But this is not a flexible design. What
happens if we need to replace a low level class?
Example
Violations of Dependency Inversion Principle
We have to change the Manager class (remember
it is a complex one and this will involve time and
effort to make the changes).
Some of the current functionality from the
manager class might be affected.
The unit testing should be redone.
All those problems could take a lot of time to be
solved and they might induce new errors in the
old functionality.
Benefits of Dependency Inversion Principle
Manager class doesn't require changes when
adding SuperWorkers.
Minimized risk to affect old functionality present
in Manager class since we don't change it.
No need to redo the unit testing for Manager
class.
Quality Attributes of Design principles
Understandability:- The ease with which the
design fragment can be comprehended.
Changeability:- The ease with which a design
fragment can be modified when an existing
functionality is changed.
Extensibility:- The ease with which a design
fragment can be enhanced or extended for
suporting new functionality
Quality Attributes of Design principles
Reusability:- The ease with which a design
fragment can be used in a problem context other
than the one for which the design fragment was
originally developed.
Testability:- The ease with which a design
fragment supports the detection of defects within
it via testing.
Reliability:- The extent to which the design
fragment supports the correct realization fo the
functionality and helps guard against the
introduction of runtime problems.
Q & A ?
Thank You !!!!
Enjoy following principles….
Follow me @avidnyat

More Related Content

What's hot

Software design principles
Software design principlesSoftware design principles
Software design principlesMd.Mojibul Hoque
 
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
 
Six Principles of Software Design to Empower Scientists
Six Principles of Software Design to Empower ScientistsSix Principles of Software Design to Empower Scientists
Six Principles of Software Design to Empower ScientistsDavid De Roure
 
Design principle vs design patterns
Design principle vs design patternsDesign principle vs design patterns
Design principle vs design patternsPrabhakar Sharma
 
Software Design Principles
Software Design PrinciplesSoftware Design Principles
Software Design PrinciplesOcean Dong
 
The SOLID Principles Illustrated by Design Patterns
The SOLID Principles Illustrated by Design PatternsThe SOLID Principles Illustrated by Design Patterns
The SOLID Principles Illustrated by Design PatternsHayim Makabee
 
Bartlesville Dot Net User Group Design Patterns
Bartlesville Dot Net User Group Design PatternsBartlesville Dot Net User Group Design Patterns
Bartlesville Dot Net User Group Design PatternsJason Townsend, MBA
 
Clean Code .Net Cheetsheets
Clean Code .Net CheetsheetsClean Code .Net Cheetsheets
Clean Code .Net CheetsheetsNikitaGoncharuk1
 
NoSQL Introduction, Theory, Implementations
NoSQL Introduction, Theory, ImplementationsNoSQL Introduction, Theory, Implementations
NoSQL Introduction, Theory, ImplementationsFirat Atagun
 
How I Learned To Apply Design Patterns
How I Learned To Apply Design PatternsHow I Learned To Apply Design Patterns
How I Learned To Apply Design PatternsAndy Maleh
 
SOLID Software Principles with C#
SOLID Software Principles with C#SOLID Software Principles with C#
SOLID Software Principles with C#Ken Burkhardt
 
Learning solid principles using c#
Learning solid principles using c#Learning solid principles using c#
Learning solid principles using c#Aditya Kumar Rajan
 
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
 
The Solid Principles
The Solid PrinciplesThe Solid Principles
The Solid PrinciplesLuke Smith
 
Refactoring Applications using SOLID Principles
Refactoring Applications using SOLID PrinciplesRefactoring Applications using SOLID Principles
Refactoring Applications using SOLID PrinciplesSteven Smith
 
GRASP Principles
GRASP PrinciplesGRASP Principles
GRASP PrinciplesRaheel Arif
 
Introduction To Design Patterns
Introduction To Design PatternsIntroduction To Design Patterns
Introduction To Design Patternssukumarraju6
 

What's hot (20)

Software design principles
Software design principlesSoftware design principles
Software design principles
 
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
 
Six Principles of Software Design to Empower Scientists
Six Principles of Software Design to Empower ScientistsSix Principles of Software Design to Empower Scientists
Six Principles of Software Design to Empower Scientists
 
Design principle vs design patterns
Design principle vs design patternsDesign principle vs design patterns
Design principle vs design patterns
 
Software Design Principles
Software Design PrinciplesSoftware Design Principles
Software Design Principles
 
Microservices
MicroservicesMicroservices
Microservices
 
The SOLID Principles Illustrated by Design Patterns
The SOLID Principles Illustrated by Design PatternsThe SOLID Principles Illustrated by Design Patterns
The SOLID Principles Illustrated by Design Patterns
 
Bartlesville Dot Net User Group Design Patterns
Bartlesville Dot Net User Group Design PatternsBartlesville Dot Net User Group Design Patterns
Bartlesville Dot Net User Group Design Patterns
 
Principle of OOD
Principle of OODPrinciple of OOD
Principle of OOD
 
Clean Code .Net Cheetsheets
Clean Code .Net CheetsheetsClean Code .Net Cheetsheets
Clean Code .Net Cheetsheets
 
NoSQL Introduction, Theory, Implementations
NoSQL Introduction, Theory, ImplementationsNoSQL Introduction, Theory, Implementations
NoSQL Introduction, Theory, Implementations
 
How I Learned To Apply Design Patterns
How I Learned To Apply Design PatternsHow I Learned To Apply Design Patterns
How I Learned To Apply Design Patterns
 
SOLID Software Principles with C#
SOLID Software Principles with C#SOLID Software Principles with C#
SOLID Software Principles with C#
 
Learning solid principles using c#
Learning solid principles using c#Learning solid principles using c#
Learning solid principles using c#
 
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
 
The Solid Principles
The Solid PrinciplesThe Solid Principles
The Solid Principles
 
Refactoring Applications using SOLID Principles
Refactoring Applications using SOLID PrinciplesRefactoring Applications using SOLID Principles
Refactoring Applications using SOLID Principles
 
Clean code-v2.2
Clean code-v2.2Clean code-v2.2
Clean code-v2.2
 
GRASP Principles
GRASP PrinciplesGRASP Principles
GRASP Principles
 
Introduction To Design Patterns
Introduction To Design PatternsIntroduction To Design Patterns
Introduction To Design Patterns
 

Viewers also liked

Solid Principles Of Design (Design Series 01)
Solid Principles Of Design (Design Series 01)Solid Principles Of Design (Design Series 01)
Solid Principles Of Design (Design Series 01)Heartin Jacob
 
Introduction to SOLID Principles
Introduction to SOLID PrinciplesIntroduction to SOLID Principles
Introduction to SOLID PrinciplesGanesh Samarthyam
 
SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design PrinciplesSamuel Breed
 
Object Oriented Design SOLID Principles
Object Oriented Design SOLID PrinciplesObject Oriented Design SOLID Principles
Object Oriented Design SOLID Principlesrainynovember12
 
SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design PrinciplesAndreas Enbohm
 
Advanced Object-Oriented/SOLID Principles
Advanced Object-Oriented/SOLID PrinciplesAdvanced Object-Oriented/SOLID Principles
Advanced Object-Oriented/SOLID PrinciplesJon Kruger
 
S.O.L.I.D. Principles for Software Architects
S.O.L.I.D. Principles for Software ArchitectsS.O.L.I.D. Principles for Software Architects
S.O.L.I.D. Principles for Software ArchitectsRicardo Wilkins
 
SOLID Principles and Design Patterns
SOLID Principles and Design PatternsSOLID Principles and Design Patterns
SOLID Principles and Design PatternsGanesh Samarthyam
 
Introduction to SOLID Principles
Introduction to SOLID PrinciplesIntroduction to SOLID Principles
Introduction to SOLID PrinciplesDave Cook
 
Object Oriented Design Principles - SOLID
Object Oriented Design Principles - SOLIDObject Oriented Design Principles - SOLID
Object Oriented Design Principles - SOLIDTom Crinson
 
Design principles - SOLID
Design principles - SOLIDDesign principles - SOLID
Design principles - SOLIDPranalee Rokde
 
SOLID - Principles of Object Oriented Design
SOLID - Principles of Object Oriented DesignSOLID - Principles of Object Oriented Design
SOLID - Principles of Object Oriented DesignRiccardo Cardin
 

Viewers also liked (15)

Solid Principles Of Design (Design Series 01)
Solid Principles Of Design (Design Series 01)Solid Principles Of Design (Design Series 01)
Solid Principles Of Design (Design Series 01)
 
Introduction to SOLID Principles
Introduction to SOLID PrinciplesIntroduction to SOLID Principles
Introduction to SOLID Principles
 
SOLID principles
SOLID principlesSOLID principles
SOLID principles
 
SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design Principles
 
Object Oriented Design SOLID Principles
Object Oriented Design SOLID PrinciplesObject Oriented Design SOLID Principles
Object Oriented Design SOLID Principles
 
SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design Principles
 
Advanced Object-Oriented/SOLID Principles
Advanced Object-Oriented/SOLID PrinciplesAdvanced Object-Oriented/SOLID Principles
Advanced Object-Oriented/SOLID Principles
 
S.O.L.I.D. Principles for Software Architects
S.O.L.I.D. Principles for Software ArchitectsS.O.L.I.D. Principles for Software Architects
S.O.L.I.D. Principles for Software Architects
 
SOLID Principles and Design Patterns
SOLID Principles and Design PatternsSOLID Principles and Design Patterns
SOLID Principles and Design Patterns
 
Introduction to SOLID Principles
Introduction to SOLID PrinciplesIntroduction to SOLID Principles
Introduction to SOLID Principles
 
Object Oriented Design Principles - SOLID
Object Oriented Design Principles - SOLIDObject Oriented Design Principles - SOLID
Object Oriented Design Principles - SOLID
 
Solid principles
Solid principlesSolid principles
Solid principles
 
SOLID Principles part 1
SOLID Principles part 1SOLID Principles part 1
SOLID Principles part 1
 
Design principles - SOLID
Design principles - SOLIDDesign principles - SOLID
Design principles - SOLID
 
SOLID - Principles of Object Oriented Design
SOLID - Principles of Object Oriented DesignSOLID - Principles of Object Oriented Design
SOLID - Principles of Object Oriented Design
 

Similar to Soild principles

DesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatternsDesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatternsBasavaraj Patil
 
Design Principles to design Patterns
Design Principles to design PatternsDesign Principles to design Patterns
Design Principles to design PatternsFaizan Haider
 
Clean code: SOLID (iOS)
Clean code: SOLID (iOS)Clean code: SOLID (iOS)
Clean code: SOLID (iOS)Maksym Husar
 
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
 
OO design principle
OO design principleOO design principle
OO design principleLi-Wei Cheng
 
Clean Code - Part 2
Clean Code - Part 2Clean Code - Part 2
Clean Code - Part 2Knoldus Inc.
 
SOLID Design Principles for Test Automaion
SOLID Design Principles for Test AutomaionSOLID Design Principles for Test Automaion
SOLID Design Principles for Test AutomaionKnoldus Inc.
 
Solid Principles, for better cohesion and lower coupling
Solid Principles, for better cohesion and lower coupling Solid Principles, for better cohesion and lower coupling
Solid Principles, for better cohesion and lower coupling Mohammad Shawahneh
 
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
 
Sec1_SOLID Principles_Software Engineering.pptx
Sec1_SOLID Principles_Software Engineering.pptxSec1_SOLID Principles_Software Engineering.pptx
Sec1_SOLID Principles_Software Engineering.pptxHebaSamy22
 
Evgeniy Khyst - why does software design matter and how to keep it in good shape
Evgeniy Khyst - why does software design matter and how to keep it in good shapeEvgeniy Khyst - why does software design matter and how to keep it in good shape
Evgeniy Khyst - why does software design matter and how to keep it in good shapeAnna Shymchenko
 
Episode 21 - Design Pattern 1
Episode 21 - Design Pattern 1Episode 21 - Design Pattern 1
Episode 21 - Design Pattern 1Jitendra Zaa
 
GDSC - SOLID Principles session.pptx
GDSC - SOLID Principles session.pptxGDSC - SOLID Principles session.pptx
GDSC - SOLID Principles session.pptxAaliyanShaikh
 
Inversion of Control
Inversion of ControlInversion of Control
Inversion of ControlShuhab Tariq
 
Dependency Injection, Design Principles and Patterns
Dependency Injection, Design Principles and PatternsDependency Injection, Design Principles and Patterns
Dependency Injection, Design Principles and PatternsJuan Lopez
 
Tdd and-design-draft
Tdd and-design-draftTdd and-design-draft
Tdd and-design-draftPrabudhGupta1
 

Similar to Soild principles (20)

DesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatternsDesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatterns
 
Design Principles to design Patterns
Design Principles to design PatternsDesign Principles to design Patterns
Design Principles to design Patterns
 
Clean code: SOLID (iOS)
Clean code: SOLID (iOS)Clean code: SOLID (iOS)
Clean code: SOLID (iOS)
 
Clean code: SOLID
Clean code: SOLIDClean code: SOLID
Clean code: SOLID
 
Solid Principles
Solid PrinciplesSolid Principles
Solid Principles
 
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.
 
OO design principle
OO design principleOO design principle
OO design principle
 
Clean Code - Part 2
Clean Code - Part 2Clean Code - Part 2
Clean Code - Part 2
 
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, for better cohesion and lower coupling
Solid Principles, for better cohesion and lower coupling Solid Principles, for better cohesion and lower coupling
Solid Principles, for better cohesion and lower coupling
 
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
 
Sec1_SOLID Principles_Software Engineering.pptx
Sec1_SOLID Principles_Software Engineering.pptxSec1_SOLID Principles_Software Engineering.pptx
Sec1_SOLID Principles_Software Engineering.pptx
 
Android architecture
Android architectureAndroid architecture
Android architecture
 
Evgeniy Khyst - why does software design matter and how to keep it in good shape
Evgeniy Khyst - why does software design matter and how to keep it in good shapeEvgeniy Khyst - why does software design matter and how to keep it in good shape
Evgeniy Khyst - why does software design matter and how to keep it in good shape
 
Episode 21 - Design Pattern 1
Episode 21 - Design Pattern 1Episode 21 - Design Pattern 1
Episode 21 - Design Pattern 1
 
GDSC - SOLID Principles session.pptx
GDSC - SOLID Principles session.pptxGDSC - SOLID Principles session.pptx
GDSC - SOLID Principles session.pptx
 
android principle.pptx
android principle.pptxandroid principle.pptx
android principle.pptx
 
Inversion of Control
Inversion of ControlInversion of Control
Inversion of Control
 
Dependency Injection, Design Principles and Patterns
Dependency Injection, Design Principles and PatternsDependency Injection, Design Principles and Patterns
Dependency Injection, Design Principles and Patterns
 
Tdd and-design-draft
Tdd and-design-draftTdd and-design-draft
Tdd and-design-draft
 

Recently uploaded

System Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingSystem Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingBootNeck1
 
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...Stork
 
Katarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School CourseKatarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School Coursebim.edu.pl
 
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书rnrncn29
 
TEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACHTEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACHSneha Padhiar
 
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...Sumanth A
 
Novel 3D-Printed Soft Linear and Bending Actuators
Novel 3D-Printed Soft Linear and Bending ActuatorsNovel 3D-Printed Soft Linear and Bending Actuators
Novel 3D-Printed Soft Linear and Bending ActuatorsResearcher Researcher
 
"Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ..."Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ...Erbil Polytechnic University
 
CS 3251 Programming in c all unit notes pdf
CS 3251 Programming in c all unit notes pdfCS 3251 Programming in c all unit notes pdf
CS 3251 Programming in c all unit notes pdfBalamuruganV28
 
multiple access in wireless communication
multiple access in wireless communicationmultiple access in wireless communication
multiple access in wireless communicationpanditadesh123
 
CME 397 - SURFACE ENGINEERING - UNIT 1 FULL NOTES
CME 397 - SURFACE ENGINEERING - UNIT 1 FULL NOTESCME 397 - SURFACE ENGINEERING - UNIT 1 FULL NOTES
CME 397 - SURFACE ENGINEERING - UNIT 1 FULL NOTESkarthi keyan
 
Robotics Group 10 (Control Schemes) cse.pdf
Robotics Group 10  (Control Schemes) cse.pdfRobotics Group 10  (Control Schemes) cse.pdf
Robotics Group 10 (Control Schemes) cse.pdfsahilsajad201
 
Main Memory Management in Operating System
Main Memory Management in Operating SystemMain Memory Management in Operating System
Main Memory Management in Operating SystemRashmi Bhat
 
DEVICE DRIVERS AND INTERRUPTS SERVICE MECHANISM.pdf
DEVICE DRIVERS AND INTERRUPTS  SERVICE MECHANISM.pdfDEVICE DRIVERS AND INTERRUPTS  SERVICE MECHANISM.pdf
DEVICE DRIVERS AND INTERRUPTS SERVICE MECHANISM.pdfAkritiPradhan2
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionMebane Rash
 
Research Methodology for Engineering pdf
Research Methodology for Engineering pdfResearch Methodology for Engineering pdf
Research Methodology for Engineering pdfCaalaaAbdulkerim
 
Python Programming for basic beginners.pptx
Python Programming for basic beginners.pptxPython Programming for basic beginners.pptx
Python Programming for basic beginners.pptxmohitesoham12
 
Input Output Management in Operating System
Input Output Management in Operating SystemInput Output Management in Operating System
Input Output Management in Operating SystemRashmi Bhat
 
Immutable Image-Based Operating Systems - EW2024.pdf
Immutable Image-Based Operating Systems - EW2024.pdfImmutable Image-Based Operating Systems - EW2024.pdf
Immutable Image-Based Operating Systems - EW2024.pdfDrew Moseley
 
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENTFUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENTSneha Padhiar
 

Recently uploaded (20)

System Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingSystem Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event Scheduling
 
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
 
Katarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School CourseKatarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School Course
 
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
 
TEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACHTEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACH
 
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
 
Novel 3D-Printed Soft Linear and Bending Actuators
Novel 3D-Printed Soft Linear and Bending ActuatorsNovel 3D-Printed Soft Linear and Bending Actuators
Novel 3D-Printed Soft Linear and Bending Actuators
 
"Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ..."Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ...
 
CS 3251 Programming in c all unit notes pdf
CS 3251 Programming in c all unit notes pdfCS 3251 Programming in c all unit notes pdf
CS 3251 Programming in c all unit notes pdf
 
multiple access in wireless communication
multiple access in wireless communicationmultiple access in wireless communication
multiple access in wireless communication
 
CME 397 - SURFACE ENGINEERING - UNIT 1 FULL NOTES
CME 397 - SURFACE ENGINEERING - UNIT 1 FULL NOTESCME 397 - SURFACE ENGINEERING - UNIT 1 FULL NOTES
CME 397 - SURFACE ENGINEERING - UNIT 1 FULL NOTES
 
Robotics Group 10 (Control Schemes) cse.pdf
Robotics Group 10  (Control Schemes) cse.pdfRobotics Group 10  (Control Schemes) cse.pdf
Robotics Group 10 (Control Schemes) cse.pdf
 
Main Memory Management in Operating System
Main Memory Management in Operating SystemMain Memory Management in Operating System
Main Memory Management in Operating System
 
DEVICE DRIVERS AND INTERRUPTS SERVICE MECHANISM.pdf
DEVICE DRIVERS AND INTERRUPTS  SERVICE MECHANISM.pdfDEVICE DRIVERS AND INTERRUPTS  SERVICE MECHANISM.pdf
DEVICE DRIVERS AND INTERRUPTS SERVICE MECHANISM.pdf
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of Action
 
Research Methodology for Engineering pdf
Research Methodology for Engineering pdfResearch Methodology for Engineering pdf
Research Methodology for Engineering pdf
 
Python Programming for basic beginners.pptx
Python Programming for basic beginners.pptxPython Programming for basic beginners.pptx
Python Programming for basic beginners.pptx
 
Input Output Management in Operating System
Input Output Management in Operating SystemInput Output Management in Operating System
Input Output Management in Operating System
 
Immutable Image-Based Operating Systems - EW2024.pdf
Immutable Image-Based Operating Systems - EW2024.pdfImmutable Image-Based Operating Systems - EW2024.pdf
Immutable Image-Based Operating Systems - EW2024.pdf
 
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENTFUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
 

Soild principles

  • 2. Design Principles!!!! Software design principles represent a set of guidelines that helps us to avoid having a bad design.
  • 3. “ ● Rigidity - It is hard to change because every change affects too many other parts of the system. ● Fragility - When you make a change, unexpected parts of the system break. ● Immobility - It is hard to reuse in another application because it cannot be disentangled from the current application. Characteristics of bad design
  • 4. Design Principles Open Close Principle Interface Segregation Principle Single Responsibility Principle Dependency Inversion Principle Liskov’s Substitution Principle
  • 5. 1. Single Responsibility Principle A class should have only one reason to change.
  • 8. Single Responsibility Principle There should be only one reason to change class. If reasons are two then split the class. To keep class more atomized as possible. The concept could be extended to the methods of class too, keeping easy the management of all internal structure.
  • 9. Benefits Of Single Responsibility Principle Easier to test, read and maintain. Less side effects. Separation of concerns. Naming does’nt gets tricky.
  • 11.
  • 12. Violation of SRP 3 reasons to change one class. If one of the method breaks all modules depending on it will break. Reading and maintaining becomes difficult. Reusability is less. Low cohesion, tightly coupled If there is any new change to the class, developer has to understand complete class all methods of that class and then can start working on it. As well as tester has to test all methods again instead of testing only added change. Best example to give is fixing one bug raises 10 or more bugs
  • 13.
  • 14.
  • 15.
  • 16. Benefits of SRP Only 1 reason to change one class. Reading and maintaining becomes easy. Reusability is more. High cohesion, loosely coupled If there is any new change to the class, developer has to understand only one class and methods of that class and then can start working on it. As well as tester has to test few methods.
  • 17. Attribute Of SRP - Cohesion High cohesion. Cohesion refers to the degree with which elements of code belong together. This means that the level of cohesion between elements is higher if they are related, and lower if they are not. Having a class with many methods that do one job means that class has high cohesion.
  • 18. Attribute Of SRP - Coupling Low coupling. Coupling is the manner of independence between modules of a programming system. This means that high coupling means that modules are more dependent upon one another, and low coupling means they are less dependent. Having a class with many methods that do one job means that that class has high cohesion.
  • 19. 2. Open Closed Principle Open for extension and closed for modification
  • 20. Open Close Principle Real Example Open for extension and close for modification
  • 21. Open Close Principle An adapter in the wall is always closed for modification, in other words we cannot change it once it is fitted or extended if we want more. But an adapter always provides a method of extension, so we can plug in an extension board of an adapter for more adaptation. So you plug in an extension board and extend an existing electric adapter fitted in wall.
  • 22. Open Close Principle OPC is a generic principle. You can consider it when writing your classes to make sure that when you need to extend their behavior you don’t have to change the class but to extend it. The same principle can be applied for modules, packages, libraries. If you have a library containing a set of classes there are many reasons for which you will prefer to extend it without changing the code that was already written.
  • 24.
  • 25. Violation of Open Close Principle Open for modification and closed for extension If one of the method breaks all modules depending on it will break. Reading and maintaining becomes difficult. Reusability is less. If there is any new change to the class, developer has to understand complete class all methods of that class and then can start working on it. As well as tester has to test all methods again instead of testing only added change. Best example to give is fixing one bug raises 10 or more bugs
  • 26.
  • 27. Pros of Open Close Principle Open for extension and closed for modification If one of the method breaks other modules still remain intact. Reusability is high. If there is any new change to the class, developer does not have to understand complete class all methods of that class and then can start working on it. As well as tester does not have to test all methods again instead of that has to test only one change. Applying strategy design pattern or template design pattern helps in solving problem.
  • 28. 3. Liskov’s Substituion Principle Derived types must be completely substitutable for their base types.
  • 29.
  • 30. Liskov’s Substitution Principle This principle is just an extension of the Open Close Principle in terms of behavior meaning that we must make sure that new derived classes are extending the base classes without changing their behavior. The new derived classes should be able to replace the base classes without any change in the code.
  • 32.
  • 33.
  • 34.
  • 35. Cons of Liskov’s Substitution Principle Difficult to understand why it broked after substitution. Developer has to understand and remember all derived types and extra operations that class does. Difficult to change client code after substitution.
  • 36.
  • 37. 4. Interface Segregation Principle Clients should not be forced to depend upon interfaces that they don't use.
  • 38.
  • 39.
  • 40.
  • 41. Interface Segregation Principle This principle teaches us to take care how we write our interfaces. When we write our interfaces we should take care to add only methods that should be there. If we add methods that should not be there the classes implementing the interface will have to implement those methods as well. As a conclusion Interfaces containing methods that are not specific to it are called polluted or fat interfaces. We should avoid them.
  • 43.
  • 44.
  • 45. Violations of Interface Segregation Principle If robot class does not need eat method still it is forced to implement. As interface is polluted for any new change developer has to understand complete class. Reusability with huge cost
  • 46.
  • 47.
  • 48. Pros of Interface Segregation Principle Easy to read and understand. Loosely coupled. Reusability with low cost. Developer has to understand only one interface with small unit of code.
  • 49. 5. 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.
  • 50.
  • 51. Dependency Inversion Principle Dependency Inversion Principle states that we should decouple high level modules from low level modules, introducing an abstraction layer between the high level classes and low level classes.
  • 52. Dependency Inversion Principle In the classical way when a software module(class, framework) need some other module, it initializes and holds a direct reference to it. This will make the 2 modules tight coupled. In order to decouple them the first module will provide a hook(a property, parameter) and an external module controlling the dependencies will inject the reference to the second one.
  • 53. Dependency Inversion Principle When we design software applications we can consider the low level classes the classes which implement basic and primary operations(disk access, network protocols,...) and high level classes the classes which encapsulate complex logic(business flows, ...). The last ones rely on the low level classes. A natural way of implementing such structures would be to write low level classes and once we have them to write the complex high level classes. Since high level classes are defined in terms of others this seems the logical way to do it. But this is not a flexible design. What happens if we need to replace a low level class?
  • 55.
  • 56. Violations of Dependency Inversion Principle We have to change the Manager class (remember it is a complex one and this will involve time and effort to make the changes). Some of the current functionality from the manager class might be affected. The unit testing should be redone. All those problems could take a lot of time to be solved and they might induce new errors in the old functionality.
  • 57.
  • 58. Benefits of Dependency Inversion Principle Manager class doesn't require changes when adding SuperWorkers. Minimized risk to affect old functionality present in Manager class since we don't change it. No need to redo the unit testing for Manager class.
  • 59. Quality Attributes of Design principles Understandability:- The ease with which the design fragment can be comprehended. Changeability:- The ease with which a design fragment can be modified when an existing functionality is changed. Extensibility:- The ease with which a design fragment can be enhanced or extended for suporting new functionality
  • 60. Quality Attributes of Design principles Reusability:- The ease with which a design fragment can be used in a problem context other than the one for which the design fragment was originally developed. Testability:- The ease with which a design fragment supports the detection of defects within it via testing. Reliability:- The extent to which the design fragment supports the correct realization fo the functionality and helps guard against the introduction of runtime problems.
  • 61.
  • 62. Q & A ?
  • 63. Thank You !!!! Enjoy following principles…. Follow me @avidnyat