Real-World Sample Code
參考http://www.dofactory.com/Patterns/Patterns.aspx
Demo |
常用 |
Creational Patterns |
|
|
5 |
Creates an instance of several families of classes |
|
|
2 |
Separates object construction from its representation |
|
|
5 |
Creates an instance of several derived classes |
|
3 |
A fully initialized instance to be copied or cloned |
||
4 |
A class of which only a single instance can exist |
Demo |
|
Structural Patterns |
|
|
4 |
Match interfaces of different classes |
|
|
3 |
Separates an object’s interface from its implementation |
|
|
4 |
A tree structure of simple and composite objects |
|
|
3 |
Add responsibilities to objects dynamically |
|
5 |
A single class that represents an entire subsystem |
||
|
1 |
A fine-grained instance used for efficient sharing |
|
|
4 |
An object representing another object |
Demo |
|
Behavioral Patterns |
|
|
2 |
A way of passing a request between a chain of objects |
|
|
4 |
Encapsulate a command request as an object |
|
|
1 |
A way to include language elements in a program |
|
|
5 |
Sequentially access the elements of a collection |
|
|
2 |
Defines simplified communication between classes |
|
|
1 |
Capture and restore an object's internal state |
|
|
5 |
A way of notifying change to a number of classes |
|
|
3 |
Alter an object's behavior when its state changes |
|
|
4 |
Encapsulates an algorithm inside a class |
|
|
3 |
Defer the exact steps of an algorithm to a subclass |
|
|
1 |
Defines a new operation to a class without change |
留言列表