Single Responsibility Principle

SRP

  • A module should be responsible to one actor
  • A module should serve for one client.
  • It means coupled resposibilities should be segregated
  • A class should implement only one functionality
A module which has over one functionality is responsible to many. It is likely to be strongly coupled. It makes test harder and maintenance cost higher. SRP is good for reuse and maintenance on the oter hand, increase number of objects and class hierachey and structure become complex. Dependency Inversion Principle and Interface Segregation Principle are solutions for SRP.


Comments