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 or altogether useless. Furthermore, the simple syntactical cost of declaring a class often compels programmers to marginalize.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset