SRP
The SRP states that every class should have a single responsibility, where a responsibility is defined as a reason to change.
This principle supports the anti-pattern where large classes play multiple roles. Classes can be large for a few reasons. A core principle of OOP is the binding of the data structure to behavior. The problem is that optimizing for data--structure encapsulation not only weakens composition characteristics, but also hides the underlying problem of explicit state. As a result, OOP code typically contains many data structures, with relatively few functions per data structure. Adding methods to a class brings pressure on the SRP, and reducing the number of methods can either make the data structure difficult to compose ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access