1 / 71
文档名称:

软件设计模式二.ppt

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

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

分享

预览

软件设计模式二.ppt

上传人:274030239 2021/8/1 文件大小:453 KB

下载得到文件列表

软件设计模式二.ppt

文档介绍

文档介绍:软件设计模式(二)
2003-12-19
1
内容
复****br/>续:介绍一些重要的模式
Structural Patterns
Behavioral Patterns
补充一些模式
2
复****pattern定义
定义:
特定环境中问题的成功解决方案中的静态、动态结构,以及结构元素相互之间的协作关系
the design patterns are descriptions of communicating objects and classes that are customized to solve a general design problem in a particular context
关于pattern的研究状况
研究历史
现状
pattern与框架
pattern的分类
粒度
3
复****如何描述一个模式
关键要素
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
4
复****creational patters
Factory Method
本质:用一个virtual method完成创建过程
Abstract Factory
一个product族的factory method构成了一个factory接口
Prototype
通过product原型来构造product,Clone+prototype manager
Builder
通过一个构造算法和builder接口把构造过程与客户隔离开
Singleton
单实例类型,如何构造这单个实例?如何访问这单个实例?
Finder
把对象的获取过程与客户隔离开
5
creational patterns小结
了解每一种模式的实质
具体实现的时候可能会有变化情况,或者扩展,或者退化
factory method是基础,abstract factory是它的扩展
factory method、abstract factory、prototype都涉及到类层次结构中对象的创建过程,有所取舍
prototype需要prototype manager
factory method需要依附一个creator类
abstract factory需要一个平行的类层次
根据应用的其他需求,以及语言提供的便利来决定使用哪种模式
6
creational patterns小结(续)
builder往往适合于特定的结构需要,它所针对的product比较复杂
singleton有比较强烈的物理意义,可以用在许多细微的地方,不一定与类层次关联
finder模式需要有一定范围内的对象管理功能
这些patterns都很常见,有时需要结合两种或者多种模式完成系统中对象的构造过程
7
Structural Patterns
Adapter
*Bridge
Composite
* Decorator
*Facade
Flyweight
* Proxy
8
模式 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.
9
Adapter模式(二)
Applicability:Use the Adapter pattern when
you want to use an existing class, and its interface does not match the