Big talk design mode note single duty principle open-closed principle

Source: Internet
Author: User

Single responsibility principle (SRP), in the case of a class, there should be only one cause for its change.

Personally think that this principle is too idealistic, only one is not absolute, reasonable is good.

Much of what software is designed to do is to discover responsibilities and separate those responsibilities from "ASD"

If you can think of more than one motive to change a class, then this class has more than one responsibility.

MVC, it can be said that the principle of good use, but sometimes some small projects can be directly executed in the service SQL statement, is also possible.

The open-close principle is that software entities (classes, modules, functions, and so on) should be expandable, but not modifiable.

For the expansion is open (open for extension), the change is closed (Closed for modification).

But no matter how "closed" the module is, there will be some changes that cannot be closed to it, since it is not possible to completely close, the designer must choose the module that he designed should be closed to that change. He must first guess what kinds of changes are most likely to occur and then construct abstractions to isolate those changes.

Big talk design mode note single duty principle open-closed principle

Related Article

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.