Design Mode 01

Source: Internet
Author: User

 

 

Design Mode 01 table of contents
  • 1. Design Mode
    • 1.1 Basic Principles
    • 1.2 Open-Close Principle
      • 1.2.1 relationship with other principles
1. Design Mode 1.1 Basic Principles

The scalability of the system is guaranteed by the open-closed principle, the Lee's replacement principle, the dependency reversal principle, and the combination/aggregation Reuse Principle; the flexibility of the system is guaranteed by the open-closed principle, the Demeter principle, and the interface isolation principle; the insertability of the system is guaranteed by the principle of open-closed original principle, the principle of Lishi replacement, the principle of dependency inversion, and the principle of combination/aggregation reuse.

When a software reuse is simple and easy to maintain, it is easy to add new functions to the system, or modify an existing function. Therefore, code experts are useless; when the software is poorly designed and has poor maintainability, the Code master must use a variety of unconventional methods to continue the operation and work overtime for the purpose.

1.2 Open-Close Principle

A software should be open to expansion and closed to changes. In head first, the code should be closed like lotus in sunset glow (without changes ), open (Scalable) like lotus in the early morning; software entities shocould open for extension, but closed for modification.

This principle means that when designing a module, the module should be extended without being modified. In other words, it should be possible to change the behavior of this module without having to modify the source code, because all software systems share a common feature that their requirements will change over time, when a software system is facing new requirements, existing modules (especially the most important abstraction layer) of the system cannot be modified in the software that meets the open-closed principle, by extending existing modules (especially the most important abstract layer), new behaviors can be provided to meet the demand.

From another perspective, the open-closed principle is the principle of encapsulation of variation, which is used to write EVP, locate the variable factors of the system, and encapsulate it. In the words of [gof95]: Consider the possible changes in your design and allow these changes without causing them to lead to redesign. The variability encapsulation principle means:

  1. A variability should not be scattered in many corners of the code, but should be encapsulated into an object. different manifestations of the same variability can be reflected in sub-classes, inheritance should be seen as a method to encapsulate changes, not just a subclass derived from the parent class.
  2. One type of variability should not be mixed with another type of variability. Therefore, in a design model, the hierarchy of the class graph cannot exceed two layers. Otherwise, it means that the two kinds of variability are mixed together.
1.2.1 relationship with other principles

It is not easy to achieve the principle of opening and closing, but there are also many rules to follow. These rules also appear in the identity of design principles. They are both the means and tools of the principle of opening and closing, it is affiliated with the open-closed principle.

Date: 2014-07-04 17:21:36

Author:

Org version 7.8.06 with Emacs Version 23

Validate XHTML 1.0

Ferer "> validate XHTML 1.0

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.