SOFTWARE DESIGN
PRINCIPLES
- (SOLID)
• Single Responsibility Principle (SRP)
• Open/Closed Principle (OCP)
• Liskov Substitution Principle (LSP)
• Interface Segregation Principle (ISP)
• Dependency Inversion Principle (DIP)
SOLID
• A class | A module | A function should have;
• Only ONE purpose
• A class methods and properties should have same goal
• For different properties and different jobs, export them
to another class
Single Responsibility Principle (SRP)
A class should have one, and only one,
reason to change.
Do one thing and do it well.
Single Responsibility Principle (SRP)
Gather together the things that change for the
same reasons.
Separate those things that change for different
reasons.
• A class | A module | A function should be;
• Open for extension
• Close for modification.
• Add new functionality without changing existing code
• A change to sub-class shall not need a change on parent
Open/Closed Principle (OCP)
Software entities (classes, modules,
functions, etc.) should be open for
extension, but closed for modification.
Open/Closed Principle (OCP)
We should strive to write a code that
doesn’t have to be changed every time
requirements changed.
• Parent classes should be easily substituted with their
child class.
• The code should still work.
Liskov Substitution Principle (LSP)
Objects in a program should be replaceable
with instances of their subtypes without
altering the correctness of that program.
Liskov Substitution Principle (LSP)
Interface SegregationPrinciple (ISP)
• No child class should be forced to implement not used
methods.
• Split large interfaces into smaller ones
• Split general interfaces into more specific ones
Many client specific interfaces are better
than one general interface.
Interface SegregationPrinciple (ISP)
A Client should not be forced to implement
an interface that it doesn’t use.
Dependency Inversion Principle (DIP)
• 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.
Depend on Abstractions not on concretions.
Dependency Inversion Principle (DIP)
• Single Responsibility Principle (SRP)
• Open/Closed Principle (OCP)
• Liskov Substitution Principle (LSP)
• Interface Segregation Principle (ISP)
• Dependency Inversion Principle (DIP)
SOLID
• DRY (Don’t Repeat Yourself)
• Each small piece of code may only occur once
• KISS (Keep it simple, Stupid!)
• Piece of software code should be kept simple
• YAGNI (You ain’t gonna need it)
• Never implement a thing before you need them
OTHERDESIGN PRINCIPLES
THANKS
Muhammed Asım YILDIZ

Software Design Principles (SOLID)

  • 1.
  • 2.
    • Single ResponsibilityPrinciple (SRP) • Open/Closed Principle (OCP) • Liskov Substitution Principle (LSP) • Interface Segregation Principle (ISP) • Dependency Inversion Principle (DIP) SOLID
  • 3.
    • A class| A module | A function should have; • Only ONE purpose • A class methods and properties should have same goal • For different properties and different jobs, export them to another class Single Responsibility Principle (SRP)
  • 4.
    A class shouldhave one, and only one, reason to change. Do one thing and do it well.
  • 5.
  • 6.
    Gather together thethings that change for the same reasons. Separate those things that change for different reasons.
  • 7.
    • A class| A module | A function should be; • Open for extension • Close for modification. • Add new functionality without changing existing code • A change to sub-class shall not need a change on parent Open/Closed Principle (OCP)
  • 8.
    Software entities (classes,modules, functions, etc.) should be open for extension, but closed for modification.
  • 9.
  • 10.
    We should striveto write a code that doesn’t have to be changed every time requirements changed.
  • 11.
    • Parent classesshould be easily substituted with their child class. • The code should still work. Liskov Substitution Principle (LSP)
  • 12.
    Objects in aprogram should be replaceable with instances of their subtypes without altering the correctness of that program.
  • 13.
  • 15.
    Interface SegregationPrinciple (ISP) •No child class should be forced to implement not used methods. • Split large interfaces into smaller ones • Split general interfaces into more specific ones
  • 16.
    Many client specificinterfaces are better than one general interface.
  • 17.
  • 18.
    A Client shouldnot be forced to implement an interface that it doesn’t use.
  • 19.
    Dependency Inversion Principle(DIP) • 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.
  • 20.
    Depend on Abstractionsnot on concretions.
  • 21.
  • 22.
    • Single ResponsibilityPrinciple (SRP) • Open/Closed Principle (OCP) • Liskov Substitution Principle (LSP) • Interface Segregation Principle (ISP) • Dependency Inversion Principle (DIP) SOLID
  • 23.
    • DRY (Don’tRepeat Yourself) • Each small piece of code may only occur once • KISS (Keep it simple, Stupid!) • Piece of software code should be kept simple • YAGNI (You ain’t gonna need it) • Never implement a thing before you need them OTHERDESIGN PRINCIPLES
  • 24.