Design Patterns 5 : Bridge -- Independent variations
来源:互联网 发布:java输出语句快捷键 编辑:程序博客网 时间:2024/06/02 00:45
There are two parts in the system Abstraction (consumer) and Implementation (products), the abstraction part use the implementation part to finish some job, and both the Abstraction and the Implementation are variable.
This is the place the bridge pattern comes to save the world.
The Shape aggregate the Drawing, and has no idea how the Drawing actually do the job.
Meanwhile the Drawing has no idea about the Shape at all.
In this way if we add more shapes or introduce new drawing implementations, it won't affect the other part.
And one more thing, the "One rule, one place" strategy.
In the above design, we add protected methods Shape::drawLine(), Shape::drawCircle(), use them to call the Drawing::drawLine(), Drawing::drawCircle(), instead of calling them directly in XXX::draw().
Which remove redundancy, and encapsulate the Drawing stuff only in Shape class.
Move the commonality upper, and keep the variability lower.
- Design Patterns 5 : Bridge -- Independent variations
- Design Patterns -- Bridge
- Design Patterns - Bridge Pattern
- Bridge - Design Patterns 学习笔记 (6)
- Bridge模式 - 《Design patterns Explained》心得
- Design Pattern - Structural Patterns - Bridge Pattern
- 设计模式(Design Patterns)笔记之三:Bridge
- 大卫的Design Patterns学习笔记07:Bridge
- MapReduce Design Patterns-chapter 5
- Design Patterns
- Design Patterns
- Design Patterns
- design patterns:
- Design Patterns
- Design Patterns
- Design Patterns
- Design Patterns
- Design Patterns
- VC启动画面
- 我很差 但我不气馁
- rpm about linux
- 也谈食品安全
- C#专题图制作
- Design Patterns 5 : Bridge -- Independent variations
- 常用设计模式总结--桥接模式
- typedef和define具体的详细区别
- HDU 1521 排列组合
- (转)UNICODE与ANSI的区别
- 【补足基础】结构体作为类中成员变量(一)
- UML类图关系模式及C++代码说明
- 初来咋到,要想在此安家,先要共享3500份课后答案
- 去掉word 2007中参考文献下自动生成的横线