The single responsibility principle (Srp:single responsibility principle), also known as the single function principle, stipulates that a class should have only one reason for change.
If a class takes on too much responsibility, it is tantamount to coupling those responsibilities together. A change in one's responsibilities may weaken or inhibit the ability of this class to perform other duties. This coupling leads to a fragile design that, when changed, is subjected to unexpected damage. If you want to avoid this phenomenon, we should observe the principle of single responsibility as much as possible. The core of this principle is decoupling and enhancement of cohesion.
Benefits of a single responsibility:
1. The complexity of the class, the realization of what responsibilities are clearly defined
2. Readability improves, complexity, and of course readability improves
3. Improved usability and readability, which is of course easy to maintain.
4. The risk of change caused by the reduction, change is essential, if the interface of a single responsibility to do a good job, an interface modification only to the corresponding implementation of the class has an impact on the other interfaces have no impact, which is very important for extensibility, maintainability is very helpful.
The principles of the five major design principles (ii)---single duty principle