psahni / solid_principles_nd_design_patterns

Implementation of solid principles and most useful design patterns

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

solid_principles_nd_design_patterns

Implementation of solid principles and most useful design patterns

  1. Single Resp Principle Example
  • Example:- Taxcalculator.new(employee) => We move out logic of tax calc from employee
  1. Open closed Principle
  • Example:- VehicleInsurance, HealthInsurance, HomeInsurance
  1. Liskov Substitution Principle
  • Example:- Ostrich Bird, Fly Interface
  1. Interface Segregation Principle
  • Example:- Print Copy Scan - Have smaller interfaces or small independent modules
  1. Dependency Inversion/Dependency Injection
  • Example:- Inject a low level dependency into class. ProductCatalog Class injecting ProductRepo class
  • Payment example:- Stripe Payment, CreditCard Payment
  • Have a common interface - order.pay(StripePayment.new)
  • Abstractions should not depend upon details

About

Implementation of solid principles and most useful design patterns