SlideShare a Scribd company logo
Solid Principles
By :
Ahmed Saad Khames
Backend Lead Developer @ Shopbox
https://www.linkedin.com/in/ahmedsaadkhames/
What’s Solid Principles
In object-oriented computer programming, the term SOLID is a mnemonic acronym for
five design principles intended to make software designs more understandable, flexible
and maintainable.
Single responsibility
● A class should have only one responsibility.
● That means that for example, a Person class should only worry about the domain problem regarding the person
itself, and not for example, its persistence in the database. For that, you may want to use a PersonDAO for
example. A Person class may want to keep its responsibilities the shortest it can.
● If a class is using too many external dependencies (that is, other classes), that's a symptom that the class is
having too many responsibilities.
● This problem often comes when developers try to model the real world using objects and take it too far. Loosely
coupled applications often are not very easy to navigate and do not exactly model how the real world works.
Solid principles
Open Closed
● Classes should be extendible, but not modifiable.
● That means that adding a new field to a class is fine, but changing existing things are not. Other components on
the program may depend on said field.
Liskov substitution
● A class that expects an object of type animal should work if a subclass dog and a subclass cat are passed.
● That means that Animal should NOT have a method called bark for example, since subclasses of type cat won't be
able to bark. Classes that use the Animal class, also shouldn't depend on methods that belong to a class Dog.
● Don't do things like "If this animal is a dog, then (casts animal to dog) bark. If animal is a cat then (casts animal
to cat) meow".
Solid principles
Interface segregation
● Keep your interfaces the smallest you can.
● A teacher that also is a student should implement both the IStudent and ITeacher interfaces, instead of a single
big interface called IStudentAndTeacher.
Solid principles
Dependency inversion
● Classes should be extendible, but not modifiable.
● That means that adding a new field to a class is fine, but changing existing things are not. Other components on
the program may depend on said field.
Solid principles
References
● https://en.wikipedia.org/wiki/SOLID
● https://stackoverflow.com/questions/13692126/cant-seem-to-understand-solid-principles-and-design-
patterns
● https://www.javabrahman.com/programming-principles/single-responsibility-principle-with-example-in-
java/
● https://www.javabrahman.com/programming-principles/liskov-substitution-principal-java-example/
● https://www.javabrahman.com/programming-principles/interface-segregation-principle-explained-examples-
java/
● https://www.javabrahman.com/programming-principles/dependency-inversion-principle-example-java/
Solid principles

More Related Content

PPTX
S.O.L.I.D. principles of software development
PPTX
Becoming a better developer by using the SOLID design principles
PPTX
GDSC - SOLID Principles session.pptx
PPTX
From Good to SOLID: How to become a better PHP developer
PPTX
The good, the bad and the SOLID
PPTX
android principle.pptx
PPTX
Solid design principles
PDF
Solid Principles
S.O.L.I.D. principles of software development
Becoming a better developer by using the SOLID design principles
GDSC - SOLID Principles session.pptx
From Good to SOLID: How to become a better PHP developer
The good, the bad and the SOLID
android principle.pptx
Solid design principles
Solid Principles

Similar to Solid principles (20)

PPTX
Object Oriented, Design patterns and data modelling worshop
PPTX
PDF
SOLID design principles in Ruby
PDF
TWINS: OOP and FP - Warburton
PPTX
Is your code SOLID enough?
PPTX
PPTX
Solid design principles
PPTX
Learning solid principles using c#
PDF
How to Master Development's Solid Principles | Tutort Academy
PPTX
Clean code: SOLID
PPTX
Clean code: SOLID (iOS)
PPTX
Applied Programming and Design PrinciplesLecture 2.pptx
PDF
Solid ood
PPTX
#4 | Object Oriented Programming's SOLID Principles | Sameer Siddiqui
PPTX
Object Oriented Design SOLID Principles
PPTX
Solid principles
PDF
Solid principles
PPTX
SOLID Principles
PPT
Ood and solid principles
Object Oriented, Design patterns and data modelling worshop
SOLID design principles in Ruby
TWINS: OOP and FP - Warburton
Is your code SOLID enough?
Solid design principles
Learning solid principles using c#
How to Master Development's Solid Principles | Tutort Academy
Clean code: SOLID
Clean code: SOLID (iOS)
Applied Programming and Design PrinciplesLecture 2.pptx
Solid ood
#4 | Object Oriented Programming's SOLID Principles | Sameer Siddiqui
Object Oriented Design SOLID Principles
Solid principles
Solid principles
SOLID Principles
Ood and solid principles
Ad

Recently uploaded (20)

PDF
System and Network Administration Chapter 2
PPTX
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
AI in Product Development-omnex systems
PPTX
Introduction to Artificial Intelligence
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Understanding Forklifts - TECH EHS Solution
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PPTX
CHAPTER 2 - PM Management and IT Context
PPTX
history of c programming in notes for students .pptx
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PPTX
Online Work Permit System for Fast Permit Processing
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
System and Network Administration Chapter 2
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
Internet Downloader Manager (IDM) Crack 6.42 Build 41
AI in Product Development-omnex systems
Introduction to Artificial Intelligence
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Design an Analysis of Algorithms I-SECS-1021-03
Understanding Forklifts - TECH EHS Solution
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
CHAPTER 2 - PM Management and IT Context
history of c programming in notes for students .pptx
Odoo Companies in India – Driving Business Transformation.pdf
Online Work Permit System for Fast Permit Processing
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Which alternative to Crystal Reports is best for small or large businesses.pdf
ManageIQ - Sprint 268 Review - Slide Deck
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Ad

Solid principles

  • 1. Solid Principles By : Ahmed Saad Khames Backend Lead Developer @ Shopbox https://www.linkedin.com/in/ahmedsaadkhames/
  • 2. What’s Solid Principles In object-oriented computer programming, the term SOLID is a mnemonic acronym for five design principles intended to make software designs more understandable, flexible and maintainable.
  • 3. Single responsibility ● A class should have only one responsibility. ● That means that for example, a Person class should only worry about the domain problem regarding the person itself, and not for example, its persistence in the database. For that, you may want to use a PersonDAO for example. A Person class may want to keep its responsibilities the shortest it can. ● If a class is using too many external dependencies (that is, other classes), that's a symptom that the class is having too many responsibilities. ● This problem often comes when developers try to model the real world using objects and take it too far. Loosely coupled applications often are not very easy to navigate and do not exactly model how the real world works.
  • 5. Open Closed ● Classes should be extendible, but not modifiable. ● That means that adding a new field to a class is fine, but changing existing things are not. Other components on the program may depend on said field.
  • 6. Liskov substitution ● A class that expects an object of type animal should work if a subclass dog and a subclass cat are passed. ● That means that Animal should NOT have a method called bark for example, since subclasses of type cat won't be able to bark. Classes that use the Animal class, also shouldn't depend on methods that belong to a class Dog. ● Don't do things like "If this animal is a dog, then (casts animal to dog) bark. If animal is a cat then (casts animal to cat) meow".
  • 8. Interface segregation ● Keep your interfaces the smallest you can. ● A teacher that also is a student should implement both the IStudent and ITeacher interfaces, instead of a single big interface called IStudentAndTeacher.
  • 10. Dependency inversion ● Classes should be extendible, but not modifiable. ● That means that adding a new field to a class is fine, but changing existing things are not. Other components on the program may depend on said field.
  • 12. References ● https://en.wikipedia.org/wiki/SOLID ● https://stackoverflow.com/questions/13692126/cant-seem-to-understand-solid-principles-and-design- patterns ● https://www.javabrahman.com/programming-principles/single-responsibility-principle-with-example-in- java/ ● https://www.javabrahman.com/programming-principles/liskov-substitution-principal-java-example/ ● https://www.javabrahman.com/programming-principles/interface-segregation-principle-explained-examples- java/ ● https://www.javabrahman.com/programming-principles/dependency-inversion-principle-example-java/