Object-Oriented Design Principles (I) SRP (single responsibility principle)

Source: Internet
Author: User
SRP (single responsibility principle, single responsibility principle)

A class should have only one reason to change.

 

One class is better to do only one thing. There is only one reason for its change.
A class has only one reason for its change. Otherwise, reconstruction should be considered.
A single responsibility principle is determined by the reasons for changes, rather than functional responsibilities. Although a job is often the axis of change, sometimes it is not necessary to review the situation.
Test-driven development helps design the rational separation function.
Separation of duties can be performed in facade or proxy mode.
A class should have only one reason for its change. Instead of encapsulating the different responsibilities of the reasons for the change, it should be isolated.

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.