Single Responsibility Principle (SRP)

This is the ‘S’ in SOLID

Responsibility’s can be stated as “a reason to change”, multiple small interfaces (interface-segregation principle ISP) can help to achieve SRP.

SRP is also related to the concept of ‘Separation Of Concerns

Definition (Robert C. “Uncle Bob” Martin)

There should never be more than one reason for a class to change.

Definition (Wikipedia)

The Single Responsibility Principle states that every object should have a single responsibility, and that responsibility should be entirely encapsulated by the class.

Cohesion and Coupling

  • Cohesion is how strongly related & focused the responsibilities of a module are
  • Coupling is the degree to which each program module relies on each other

The goal would be to have low coupling and high cohesion.

References

Leave a Reply