Separation of concerns and single duty

Source: Internet
Author: User

Separation of concerns (separation of CONCERNS,SOC) is the ability to identify, encapsulate, and manipulate concerns by "identifying, encapsulating, and manipulating" the software components associated with only "specific concepts, goals, and concerns". is a principle of dealing with complexity. Because the combination of concerns leads to a significant increase in complexity, it is possible to separate the different points of concern and deal with each other as a principle of dealing with complexity, a method.

http://blog.csdn.net/lovelion/article/details/7536542

The single responsibility principle is the simplest object-oriented design principle, which is used to control the granularity of a class. The single responsibility principle is defined as follows:

Single Responsibility Principle, SRP: A class is responsible for only one functional area of responsibility, or can be defined as: For a class, there should be only one cause for it to change.

Single duty principle tells us: A class can not be too "tired"! In a software system, the more responsibilities a class (large to a module, small to a method) assumes, the less likely it is to be reused, and the more responsibilities a class carries, the equivalent of coupling those responsibilities together, and when one of the responsibilities changes, it may affect the operation of other duties, so separating those responsibilities Encapsulate different responsibilities in different classes, encapsulating different causes of change in different classes, and encapsulating them in the same class if multiple responsibilities are always changed at the same time.

The principle of single responsibility is to achieve high cohesion, low-coupling guidelines, it is the simplest but most difficult to apply the principle, the need for designers to discover the different responsibilities of the class and separate it, and the discovery of multiple responsibilities of the class requires designers have strong analytical design capabilities and relevant practical experience.

Adhere to a single responsibility principle and encapsulate different responsibilities into different classes or modules.

Single Responsibility Principle: the core of this principle is decoupling and enhancing cohesion.

Separation of concerns and single duty

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.