北京大学:《组件技术》课程教学资源(讲义课件)第十三讲 软件设计模式(二)

软件设计模式(二) 潘爱民 http://www.icst.pku.edu.cn/compcourse
软件设计模式 ( 二 ) 潘爱民 http://www.icst.pku.edu.cn/compcourse

内容 复习 续:介绍一些重要的模式 Structural patterns Behavioral patterns 第二次作业
内容 • 复习 • 续:介绍一些重要的模式 – Structural Patterns – Behavioral Patterns • 第二次作业

复习: pattern定义 定义 特定环境中问题的成功解决方案中的静态、动态结构, 以及结构元素相互之间的协作关系 Design patterns represent solutions to problems that arise when developing software within a particular context 关于 pattern的研究状况 研究历史 现状 pattern与框架 pattern分类 粒度
复习:pattern定义 • 定义: – 特定环境中问题的成功解决方案中的静态、动态结构, 以及结构元素相互之间的协作关系 – Design patterns represent solutions to problems that arise when developing software within a particular context • 关于pattern的研究状况 – 研究历史 – 现状 • pattern与框架 • pattern的分类 – 粒度

复习:如何描述一个模式 关键要素 Design pattern name, Aliases or Also Known As Problem, Intent or goal Forces, Constraints, Motivation Context, Applicability Solution · Structure Participants Collaboration Implementation Evaluation, Resulting Context, Consequences Related patterns Examples, Known uses
复习:如何描述一个模式 • 关键要素 – Design pattern name,Aliases or Also Known As – Problem,Intent or Goal – Forces,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 Factor 个 product族的 actory method构成了一个 factory接口 Prototype 通过 product原型来构造 product, Clone+ prototype manager Builder 通过一个构造算法和 builder接口把构造过程与客户隔离开 Singleton 单实例类型,如何构造这单个实例?如何访问这单个实例? Finder 把对象的获取过程与客户隔离开
复习:creational patters • Factory Method – 本质:用一个virtual method完成创建过程 • Abstract Factory – 一个product族的factory method构成了一个factory接口 • Prototype – 通过product原型来构造product,Clone+prototype manager • Builder – 通过一个构造算法和builder接口把构造过程与客户隔离开 • Singleton – 单实例类型,如何构造这单个实例?如何访问这单个实例? • Finder – 把对象的获取过程与客户隔离开

Structural patterns Adapter Bridge Composite R Decorator Facade Flyweight k Proxy
Structural Patterns • Adapter • Bridge • Composite • * Decorator • Facade • Flyweight • * Proxy

模式7: Adapter(-) Aliases: Wrapper Intent Convert the interface of a class into another inter face clients expect. Adapter lets classes work together that couldn't otherwise because of incompatible interfaces Motivation Sometimes a toolkit class that's designed for reuse isn't reusable only because its interface doesn't match the domain-specific inter face an application requires
模式 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 incompatible 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 requires

Adapter模式(二) Applicability: Use the Adapter pattern when you want to use an existing class, and its interface does not match the one you need you want to create a reusable class that cooperates with unrelated or unforeseen classes. that is. classes that don't necessarily have compatible interfaces (object adapter only) you need to use several existing subclasses, but it's impractical to adapt their interface by subclassing every one. An object adapter can adapt the interface of its parent class
Adapter模式(二) • Applicability:Use the Adapter pattern when – you want to use an existing class, and its interface does not match the one you need. – you want to create a reusable class that cooperates with unrelated or unforeseen classes, that is, classes that don't necessarily have compatible interfaces. – (object adapter only) you need to use several existing subclasses, but it's impractical to adapt their interface by subclassing every one. An object adapter can adapt the interface of its parent class

Adapter模式( Struct class Client Target Adaptee Request( SpecificRequesto) adapter (impl Adapter Request(o- SpecificRequest() object Client Target Adaptee Request( Specific Request adapter adaptee Adapter Request()o卜- adaptee->SpecificRequesto
Adapter模式(三) • Struct class adapter object adapter

Adapter模式(三) ° Participant Client、 Target、 Adaptee、 Adapter Collaborations class adapter-delegation obJect adapter container
Adapter模式(三) • Participants – Client、Target、Adaptee、Adapter • Collaborations – class adapter —— delegation – object adapter —— container
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 北京大学:《组件技术》课程教学资源(讲义课件)第十二讲 软件设计模式(一).pdf
- 北京大学:《组件技术》课程教学资源(讲义课件)第十一讲 COM+.pdf
- 北京大学:《组件技术》课程教学资源(讲义课件)第十讲 COM:moniker、UT、control.pdf
- 北京大学:《组件技术》课程教学资源(讲义课件)第九讲 COM:可连接对象&结构化存储.pdf
- 北京大学:《组件技术》课程教学资源(讲义课件)第八讲 COM开发.pdf
- 北京大学:《组件技术》课程教学资源(讲义课件)第七讲 自动化 Automation.pdf
- 北京大学:《组件技术》课程教学资源(讲义课件)第六讲 COM多线程模型、DCOM.pdf
- 北京大学:《组件技术》课程教学资源(讲义课件)第五讲 COM特性.pdf
- 北京大学:《组件技术》课程教学资源(讲义课件)第四讲 COM实现.pdf
- 北京大学:《组件技术》课程教学资源(讲义课件)第三讲 COM接口与对象.pdf
- 北京大学:《组件技术》课程教学资源(讲义课件)第二讲 C++语言基础.pdf
- 北京大学:《组件技术》课程教学资源(讲义课件)第一讲 软件领城的发展(潘爱民).pdf
- Linux爱好者入门教程.doc
- 景德镇高等专科学校:《AutoCAD 2002中文版》课程教学资源(PPT课件讲稿)第12章 图形输出.ppt
- 景德镇高等专科学校:《AutoCAD 2002中文版》课程教学资源(PPT课件讲稿)第10章 尺寸标注.ppt
- 景德镇高等专科学校:《AutoCAD 2002中文版》课程教学资源(PPT课件讲稿)第1章 启动与退出.ppt
- 景德镇高等专科学校:《AutoCAD 2002中文版》课程教学资源(PPT课件讲稿)第2章 绘图基础.ppt
- 景德镇高等专科学校:《AutoCAD 2002中文版》课程教学资源(PPT课件讲稿)第5章 绘制图形.ppt
- 景德镇高等专科学校:《AutoCAD 2002中文版》课程教学资源(PPT课件讲稿)第8章 图案填充.ppt
- 景德镇高等专科学校:《AutoCAD 2002中文版》课程教学资源(PPT课件讲稿)第7章 图块及属性.ppt
- 《数字平面艺术设计》课程教学资源(教材PPT课件,图片版)第2章 平面设计概述.ppt
- 《ASP程序设计》课程配套PPT教学课件(共十一章).ppt
- 湖北工业大学:《数据结构》第10章(10-1)查找的基本概念.ppt
- 湖北工业大学:《数据结构》第9章(9-2)哈希查找表.ppt
- 湖北工业大学:《数据结构》前言、第1章 绪论.ppt
- 湖北工业大学:《数据结构》第2章 线性表(1/4).ppt
- 湖北工业大学:《数据结构》第2章 线性表(2/4).ppt
- 湖北工业大学:《数据结构》第2章 线性表(3/4).ppt
- 湖北工业大学:《数据结构》第2章 线性表(4/4).ppt
- 湖北工业大学:《数据结构》第3章 堆栈和队列(1/3).ppt
- 湖北工业大学:《数据结构》第3章 堆栈和队列(2/3).ppt
- 湖北工业大学:《数据结构》第3章 堆栈和队列(3/3).ppt
- 湖北工业大学:《数据结构》第4章 串(String)(1/2).ppt
- 湖北工业大学:《数据结构》第4章 串(String)(2/2).ppt
- 湖北工业大学:《数据结构》第5章 数组.ppt
- 湖北工业大学:《数据结构》第6章 递归.ppt
- 湖北工业大学:《数据结构》第7章 树和二叉树(Tree & Binary Tree)(1/5).ppt
- 湖北工业大学:《数据结构》第7章 树和二叉树(Tree & Binary Tree)(2/5).ppt
- 湖北工业大学:《数据结构》第7章 树和二叉树(Tree & Binary Tree)(3/5).ppt
- 湖北工业大学:《数据结构》第7章 树和二叉树(Tree & Binary Tree)(4/5).ppt