[From design to architecture] design patterns that must be known

Source: Internet
Author: User

Released on: 2007.3.21 by anytao

2007 indicate the source of anytao.com.

This article introduces the following:

• Design & Pattern)

 

This article involves the following technologies:

Object-oriented and Design Patterns

 

Introduction

The design pattern is a collection of object-oriented ideas. In its classic works, gof summarizes 23 design patterns, which can be divided into three categories: creation, structure, and behavior. For software designers, the general process is to understand the general framework of the class library and common functions and interfaces on the basis of mastering the language background, improve understanding of software design ideas.

Software designers must be clear about their own positioning and direction. The idea of indulging in technical details is a poison that restricts the maturity of personal technologies. Therefore, learning software design and understanding software engineering are essential lessons for every developer. I do not want to describe the details of each design pattern here. I think there are already many documents on Google and Baidu. In addition, the learning methods won't be invincible if you understand all the design patterns. The learning method I emphasize is to understand the general framework on the basis of mastering the basic elements. This is not only a Learning Library method, but also a feasible design model. At the same time, remember to constantly experience and practice during the usual accumulation. Therefore, the purpose of this article is to summarize and briefly describe the key and most common design patterns that must be mastered in the 23 modes.

1 factory pattern

Reason for listing:ProgramThe operations for creating objects are handled independently, which greatly improves the flexibility of system expansion. Abstract processing of interfaces provides the best abstract mode for creating mutually dependent objects.

Recommended Hot post:. Net Design Pattern (3): abstract factory pattern (Abstract Factory)

From simple to deep learning "factory model" (3)

Switch statement, rigid poison

2 Facade Pattern

Reason for listing: isolate the presentation layer from the logic layer, encapsulate the complex processing at the underlying layer, and provide users with simple interfaces. Such examples can be seen everywhere. The facade mode is often a system architecture design. In my projects, the interface of the facade mode is implemented, providing the best solution for the decoupling of complex systems.

Recommended hot Stickers: Design Mode Study Notes (11) -- facade appearance Mode

Design Pattern Analysis-Facade Pattern (k_eckel is transferred from Microsoft University blog k_eckel's mindview)

3 Command pattern

Reason for listing: encapsulate the request as an object to separate command execution from responsibility. Usually wait for commands in the queue. How similar is this to reality. If you like to issue orders, consider your icommond.

Recommended Hot post: Command mode Application Practice

. Net design mode (17): Command pattern)

4 strategy Pattern

Reason for listing: the Policy mode encapsulates the easy-to-change part as an interface. Usually, strategy encapsulates some operationsAlgorithmTo make it interchangeable. Bruce Zhang mentioned in his blog that the policy mode is actually an interface-oriented programming method.

Recommended Hot post: Design Pattern in. Net -- strategy Pattern

Design Pattern (22)-strategy Pattern

5 iterator Pattern

Reason for listing: I believe that arrays, collections, linked lists, and queues are used in any system, so you have to care about the ins and outs of the iteration mode. In the traversal algorithm, the iteration mode provides sequential containers for traversal. The gof defines a method to access each element in a container object, without exposing the internal details of the object .. Net is used to create a set for foreach.

Recommended Hot post: iterator Pattern)

Net Design Mode (18): iterator Pattern)

6 adapter Pattern

Reason for listing: New interfaces are extended without any changes to the original type to adapt flexibly and flexibly to all old customs. This idea of breaking the old frame and adapting to the new pattern is the essence of object-oriented. The adapter mode of classes implemented in inheritance mode and the adapter mode of objects implemented in aggregation mode have their own advantages. It seems that calling it a package is nothing more than a package,

Recommended Hot post: Series 2 of "Let the cold wings fly"-from instance to adapter Mode

C # design pattern (10)-adapter Pattern

. Net design mode (8): adapter mode (adapter pattern)

7. Observer Pattern

Reason for listing: defines a one-to-many dependency between objects. When the status of an object changes, all objects dependent on it are notified and automatically updated. The separation of the observer and the observer provides a clear boundary for the module division. In. net, delegation and events can better implement the observer mode. Does event registration and cancellation correspond to the observer's observation of its objects?

Recommended Hot post:. Net practical design mode: Observer mode (observer)

Observer Pattern in AOP

. Net Design Pattern (19): Observer Pattern)

8 Bridge pattern

Reason for listing: separating implementation from logic is helpful for us to deeply understand the idea of object-oriented aggregation and reuse.

Recommended Hot post:. net design mode (9): Bridge pattern)

Difference between bridge strategy and state

Design Pattern (16)-Bridge pattern

9 Singleton pattern

Reason for listing: To improve the conflict between global variables and namespaces, it can be said that it is an improved global variable. This class has only one instance and provides a way to access global points, which ensures instance creation and access constraints more flexibly .. Net frameeork has encapsulated the singleton class. We can use it.

Recommended Hot post: From the singleton design mode of C #

. Net design mode (2): Singleton pattern)

 

Summary

The benevolent sees benevolence. The above is just the words of my family. More important insights are from practice. The application of design ideas and models also comes from continuous learning and repetition. This article is just the beginning, and the future is the constant exploration.

Suggestions

1. Do not read the gof book from the beginning. It is also a dictionary for me;

2. in software design, the design model is constantly reconstructed by requirements;

3. Learning the application of design patterns in. Net Based on the. NET Framework framework is a two-pronged process for cainiao like ours, that is, understanding the design and understanding of the Framework;

4. Share your experience.

Thank you

Thanks to gof: Erich Gamma, Richard Helm, Ralph Johnson and John vlissides, who are classic;

Thanks to Bruce Zhang, terrylee, and idior for their contributions. They are examples of the blog Park.

References

James W. Cooper, C # Design Pattern

Liu Yi, Delphi Design Model

Gof, design pattern: the basis for reusable Object-Oriented Software

2007 indicate the source of anytao.com.

This post is provided as "the status quo" without any guarantee and does not grant any rights. This posting is provided "as is" with no warranties, and confers no rights.

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.