Learning design patterns ......

Source: Internet
Author: User

Describe a recurring problem around us, and then describe the core solution to this problem, so that we can use this solution countless times without having to repeat it-Christopher Alexander

 

The purpose of the design pattern is to encapsulate the changes.

 

The basic concept of pattern can be considered as the basic concept of programming in general circumstances: adding an abstraction layer. One of the most direct motivations for isolating specific details when abstracting a thing is to separate the changed thing from the unchanged one.

 

Basic System Design Principles:

Build a system based on the most costly part of system development.

Combination is better than class inheritance.

You can use the simplest method.

 

 

The gof book discusses 23 common design patterns, which can be divided into the following three types:

1) creational: used to create an object. It usually includes the details of isolating object creation, so the Code does not depend on the object type, so you do not need to change the code when adding a new object type. For example, Singleton mode, factory mode, and builder mode;

2) structural: affects the connection mode between objects and ensures that the system does not need to change the connection between objects. For example, proxy mode and adapter mode;

3) behavioral: Processes objects with specific operation types in a program. These objects encapsulate the operation processes to be executed, such as interpreting a language, practicing a request, traversing a sequence, or implementing an algorithm. For example, command mode, template method mode, state mode, Strategy Mode, chain of responsibility mode, and observer) mode, multiple dispatching mode, and vistor mode.

 

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.