2015年12月1日 星期二

Structural Design Pattern



在寫程式中
常常需要reuse 相同的component
但因為interface 的不同,
常常需要前置及後置處理
讓程式可以運作



Adapter
Match interfaces of different classes
讓不同的interface 的class 可以互相運作

Bridge
Separates an object’s interface from its implementation
讓implementation 及abstract class 可以互相分離
各自獨立變化
但同時也造成系統的複雜度

Composite
A tree structure of simple and composite objects
Decorator
Add responsibilities to objects dynamically
Facade
A single class that represents an entire subsystem
Flyweight
A fine-grained instance used for efficient sharing
Private Class Data
Restricts accessor/mutator access
Proxy
An object representing another object

Discussion:
1. Adapter 是在舊系統和新的介面串接時,很常會用到的pattern
bridge是在設計階段,為了簡化架構,可以讓abstract class 和implementation 可以獨立變化的pattern

2. 

沒有留言: