Notes for common design patterns

Source: Internet
Author: User

Design Pattern Classification:

Creation type:

When creating an object, we do not directly instantiate the object. Instead, the program determines how to create the object based on the specific scenario, so as to ensure greater performance and better architecture advantages. The creation modes mainly include:Simple factory Mode(Not one of the 23 design patterns ),Factory methods, abstract factory models,Singleton Mode, Generator mode, and prototype mode.

Structural Type:

It is used to organize multiple objects into a larger structure. The main specification modes are adapter mode adapter,Bridging ModeBridge, bundle mode component, decorator mode decorator,Facade Mode, Hengyuan flyweight andProxy ModeProxy.

Behavior Type:

It helps communication between objects in a system and controls processes in a complex system. Behavioral patterns mainly include:Command modeInterpreter mode, iterator mode, intermediary mode, memorandum mode,Observer Mode, Status mode state,Rule ModeTemplate mode and visitor mode.

Common design patterns:

Singleton ):The core structure of Singleton only contains a special class called Singleton class. The Singleton mode ensures that there is only one instance in a class in the system and the instance is easy to access, so as to conveniently control the number of instances and save system resources. If you want to have only one class object in the system, the singleton mode is the best solution;

Bridge ):Due to actual needs, a class has more than two dimensional changes. If inheritance is used only, this requirement cannot be implemented, or the design becomes quite bloated. The bridge mode isAbstract The changesTo separate the variation part from the main class, so as to completely separate multiple changes. LastProvides a management class to combine changes in different dimensionsTo meet business needs.

CombinationMode(Composite)Not explained, that is, include

AppearanceMode(Facade):As the system continues to improve and develop, they will become more and more complex, and the system will generate a large number of classes, which makes the program process more difficult to understand. The facade mode provides a simplified interface for these classes to simplify the complexity of accessing these classes.

The facade mode (facade) is also known as the Front mode and appearance mode. This mode is used to package a complex set of classes into a simple external interface.

Observer mode (observer)

: The Observer mode defines one-to-multiple dependencies between objects, so that one or more observer objects can observe one topic object. When the status of a topic object changes, the system can notify all observer objects dependent on this object so that the observer object can be updated automatically.

 

Notes for common design patterns

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.