软件设计模式C#
Software Design Patterns in C#
设计模式(Design Patterns)是你在实际应用程序开发中,对不断发现的软件设计问题的重复解决方案。设计模式是关于对象的设计和交互,关于对经常出现的软件开发挑战的一些完美和重用的解决方案,也提供了一个交流平台,
“四人帮”(GOF)模式被认为是所有其他模式的基础,23种设计模式分为3类:创建型模式(Creational Pattern),结构型模式(Structural Pattern)和行为型模式(Behavioral Pattern)。
为了让你先起步,这里提供了2种形式的源码:结构方面的(structural)和现实应用方法的(real-world)。结构方面的代码使用模式定义和UML类图中提供的类型名称,而实际应用方面的代码提供了你需要使用模式的真实设计情况。
Creational Patterns 创建型模式 |
Abstract Factory |
Creates an instance of several families of classes |
Builder |
Separates object construction from its representation |
Factory Method |
Creates an instance of several derived classes |
Prototype |
A fully initialized instance to be copied or cloned |
Singleton |
A class of which only a single instance can exist |
Structural Patterns 结构型模式 |
Adapter |
Match interfaces of different classes |
Bridge |
Separates an object’s interface from its implementation |
Composite |
A tree structure of simple and composite objects |
Decorator |
Add responsibilities to objects dynamically |
Façade |
A single class that represents an entire subsystem |
Flyweight |
A fine-grained instance used for efficient sharing |
Proxy |
An object representing another object |
Behavioral Patterns 行为型模式 |
Chain of Resp. |
A way of passing a request between a chain of objects |
Command |
Encapsulate a command request as an object |
Interpreter |
A way to include language elements in a program |
Iterator |
Sequentially access the elements of a collection |
Mediator |
Defines simplified communication between classes |
Memento |
Capture and restore an object's internal state |
Observer |
A way of notifying change to a number of classes |
State |
Alter an object's behavior when its state changes |
Strategy |
Encapsulates an algorithm inside a class |
Template Method |
Defer the exact steps of an algorithm to a subclass |
Visitor |
Defines a new operation to a class without change |
原英文URL:
http://www.dofactory.com/Patterns/Patterns.aspx#list
上述各类模式的链接均提供了简单的解释、UML类图、Structural code(C#)和Real-world code(C#)。