Java design principles-Single duty principle (RPM)

Source: Internet
Author: User

Defined:

There should be and only one cause for class changes.

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

Advantages:

1, the complexity of the class is reduced, the realization of what responsibilities are clearly defined;

2. Readability is improved, complexity is reduced, readability of course is improved;

3, maintainability, improve readability, maintainability of course, improve;

4, the change caused by the risk of reduction, change is essential, if the interface of a single responsibility to do a good job, an interface modification only to the corresponding class has an impact on the other interfaces have no impact, which is the system's extensibility, maintenance has a great help.

Attention:

The single responsibility principle presents a standard for programming, with "responsibility" or "reason for change" to measure whether an interface or class is well designed, but "responsibility" and "reason for change" are not measurable and vary from project to environment.

Suggestions:

Interface must be a single responsibility, the design of the class as far as possible only one cause of change.

Java design principles-Single duty principle (RPM)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.