Solid Design Patterns

Posted on

Single Responsibility

  1. Do one thing and do it well
  2. Lots of small methods and lots of small classes easier to maintain
    • Need to balance granularity and maintainability
  3. Using factory is single place to create things
  4. Should only have one requirement to cause class to change
  5. Easier to find problems and identify what is responsible for error

Open-Closed Principle

  1. Be open for extension and closed for modification
  2. Once a class is done, It is done (only bug fixes can change all other changes create new classes)
  3. Make base classes generic and inherit from base classes for changes
  4. Polymorphic – Based on interfaces using API, Inheriting the interface and functionality.

Liskov Substitution Principle

  1. Derived classes can stand in for base classes
  2. Factory provides class that is needed for code

Interface Segregation Principle

  1. Make specific interfaces client specific

Dependency Inversion Principle

  1. Depend on Abstractions, Not Concrete Implementations

Focus on quality of code

  1. Don’t Repeat yourself
  2. Eliminate Technical Debt, Extract methods, Leave code cleaner than you found it
  3. Separation of concerns
  4. Think about code and what it is doing
  5. Structural, Behavioral, Procedural Patterns
  6. Program to an interface of classes using adapters
    • Allows to use mock interfaces for testing
    • Maps one thing to another
  7. Façade Makes code easier to read
  8. Decorator takes a base and decorates it
    • Not setting values of Class decorating interfacing it recursively

Leave a Reply

Your email address will not be published. Required fields are marked *