Draw Tool层次结构 CDrawTool CDraw Tool CSelectTool CRectTool CPoly Tool CSelectTool CRectTool CPolyTool
( ( $ ( %&( '' ……
例子中的模式 CDrawOI和 CDraw Tool合起来构成了 Factory Method模式 CDraw Tool: Clone用到了原型创建模式 每一个 CDraw Too都是一个 singleton Adapter/模式:把OLE对象封装成 CDrawobi *可以增加 Composite模式 facade模式:通过 CDrawDoc/View与MFC通信 chain of responsibility:如鼠标处理工作 *用 Command模式增加undo/redo功能
*+,)-./ !01 23/456701 8!"9:!"" #!$ 01 ;%<=>?. &'@ABC $ 01 (!01 DE) FDG '('$ H &' 2 !01BC !)!IJ
patter 定义: A physical arrangement of elements Repeating with some degree of correspondence in successive trials or observations 典范、范例,事物的标准样式 In the book "Design Patterns,", the design patterns are descriptions of communicating objects and classes that are customized to solve a general design problem in a particular context Design patterns represent solutions to problems that arise when developing software within a particular context 几个近义词 diom、 technique、 paradigm
! " # ! $ % &' () ! $ $ * $ + $ ! $ + ,$
pattern与 framework Patterns支持软件结构和设计的重用 抓住了特定领域中问题的成功解决方案中的静态、动态结枃和相互之 间的协作关系 patterns与开发语言无关,但是建立在一定的环境基础上 例如:经典的MVC、 Factory Method frameworks支持细节设计和代码的重用 framework是一组组件的综合,这些组件相互协作,为一族相关应用 提供了一个可重用的框架结构 例如:MMC、 MS Script Engine 两者结合起来, design patterns and frameworks有助于提高 软件的质量 比如:重用性,扩展性,性能,可维护性
• Patterns – !"#$%&'()*+,%-. /.012345 6789: – patterns;<=>?@9 ABCDE"FGHIJ – K LMVC Factory Method • frameworks – frameworkBMMNOP QRMN3478 ST39UV WXYVZ[01 – K MMC MS Script Engine • !"#$ design patterns and frameworks%&'() *+ – \K YV] ^_] ] X`a]
Design pattern =framework( a framework supplies the infrastructure and mechanisms that execute a policy for interaction between abstract components with open implementations frameworks are often said to abide by the Hollywood Principle( Don't call us, we'll call you 比较: Design patterns are more abstract than frameworks Design patterns are smaller architectural elements than frameworks Design patterns are less specialized than frameworks framework与 i class library
!"# # $ # #"%" &'()* )"$(+ ,- ! & $ ! & * ! & .#"