1 / 71
文档名称:

15软件设计模式(二).ppt

格式:ppt   页数:71页
下载后只包含 1 个 PPT 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

15软件设计模式(二).ppt

上传人:511709291 2016/4/21 文件大小:0 KB

下载得到文件列表

15软件设计模式(二).ppt

相关文档

文档介绍

文档介绍:软件设计模式(二) 潘爱民 2003-12-19 http://www. icst .pku . edu . cn /CompCourse2003/ 内容?复****续:介绍一些重要的模式– Structural Patterns – Behavioral Patterns –补充一些模式复****pattern 定义?定义: –特定环境中问题的成功解决方案中的静态、动态结构,以及结构元素相互之间的协作关系–t he design patterns are descriptions municating objects and classes that are customized to solve a general design problem in a particular context ?关于 pattern 的研究状况–研究历史–现状? pattern 与框架? pattern 的分类–粒度复****如何描述一个模式?关键要素– Design pattern name , Aliases or Also Known As – Problem , Intent or Goal – Constraints , Motivation – Context , Applicability – Solution ? Structure ? Participants ? Collaboration ? Implementation – Evaluation , Resulting Context , Consequences – Related Patterns – Examples , Known uses 复****creational patters ? Factory Method –本质:用一个 virtual method 完成创建过程? Abstract Factory –一个 product 族的 factory method 构成了一个 factory 接口? Prototype –通过 product 原型来构造 product , Clone+prototype manager ? Builder –通过一个构造算法和 builder 接口把构造过程与客户隔离开? Singleton –单实例类型,如何构造这单个实例?如何访问这单个实例? ? Finder –把对象的获取过程与客户隔离开 creational patterns 小结?了解每一种模式的实质–具体实现的时候可能会有变化情况,或者扩展,或者退化? factory method 是基础, abstract factory 是它的扩展? factory method 、 abstract factory 、 prototype 都涉及到类层次结构中对象的创建过程,有所取舍– prototype 需要 prototype manager – factory method 需要依附一个 creator 类– abstract factory 需要一个平行的类层次–根据应用的其他需求,以及语言提供的便利来决定使用哪种模式 creational patterns 小结(续) ? builder 往往适合于特定的结构需要,它所针对的 product 比较复杂? singleton 有比较强烈的物理意义,可以用在许多细微的地方,不一定与类层次关联? finder 模式需要有一定范围内的对象管理功能?这些 patterns 都很常见,有时需要结合两种或者多种模式完成系统中对象的构造过程 Structural Patterns ? Adapter ?* Bridge ? Composite ?* Decorator ?* Facade ? Flyweight ?* Proxy 模式 7: Adapter (一) ? Aliases : Wrapper ? Intent – Convert the interface of a class into another interface clients expect. Adapter lets classes work together that couldn 't otherwise because of patible interfaces. ? Motivation – Sometimes a toolkit class that's designed for reuse isn 't reusable only because its interface doesn 't match the domain-specific interface an application require