Real-World Sample Code

 

 

參考http://www.dofactory.com/Patterns/Patterns.aspx

Demo

常用

Creational Patterns

 

5

  Abstract Factory

  Creates an instance of several families of classes

 

2

  Builder

  Separates object construction from its representation

 

5

  Factory Method

  Creates an instance of several derived classes

 

3

  Prototype

  A fully initialized instance to be copied or cloned

Singleton.aspx

4

  Singleton

  A class of which only a single instance can exist

 

Demo

 

  Structural Patterns

 

4

  Adapter

  Match interfaces of different classes

 

3

  Bridge

  Separates an object’s interface from its implementation

 

4

  Composite

  A tree structure of simple and composite objects

 

3

  Decorator

  Add responsibilities to objects dynamically

Facade.aspx

5

  Facade

  A single class that represents an entire subsystem

 

1

  Flyweight

  A fine-grained instance used for efficient sharing

 

4

  Proxy

  An object representing another object

 

Demo

 

  Behavioral Patterns

 

2

  Chain of Resp.

  A way of passing a request between a chain of objects

 

4

  Command

  Encapsulate a command request as an object

 

1

  Interpreter

  A way to include language elements in a program

 

5

  Iterator

  Sequentially access the elements of a collection

 

2

  Mediator

  Defines simplified communication between classes

 

1

  Memento

  Capture and restore an object's internal state

 

5

  Observer

  A way of notifying change to a number of classes

 

3

  State

  Alter an object's behavior when its state changes

 

4

  Strategy

  Encapsulates an algorithm inside a class

 

3

  Template Method

  Defer the exact steps of an algorithm to a subclass

 

1

  Visitor

  Defines a new operation to a class without change

 

 

 

michaelfang 發表在 痞客邦 PIXNET 留言(0) 人氣()