Object-oriented principles

Source: Internet
Author: User
1 Principle of opening/closing (OCP,The Open-Closed Principle)

In principle, all software modules should be scalable, but cannot be modified. The key to following this principle is abstraction. We are writing
Module, whether it is a class or a component, you should seriously consider its real functions, its dependence on other modules, input and output
And so on. Separate the variable part (for example, using an interface or external configuration) and encapsulate the unchanged part. These unchanged parts are
Module. Here, we need to explain how to define the unchanged part when encapsulating the unchanged part. In mathematics, when we
When talking about the invariant, it is always necessary to specify under what changes it is. Otherwise it makes no sense, because the invariant under a change is very
It may not be a constant in another change. Therefore, when we define the unchanged part, we must first clarify its scope of change. However
In software development, it is difficult to know these changes accurately in advance, often based on experience or industry knowledge. So how much is this principle?
Less subjective, more like a general outline than a rigid legal provision.Martin FowlerBooksAnalysis PatternsExplained some implementations
Experience. For more information, see. The following principles describe how to arrange dependencies so that the modules are well closed, reusable, and
Maintainability.


 2. Dependency reverse principle (DIP,
<

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.