- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
潘爱民COM课件13.ppt
软件设计模式(二) 潘爱民 /CompCourse 内容 复习 续:介绍一些重要的模式 Structural Patterns Behavioral Patterns 复习: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 复习: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 couldnt otherwise because of incompatible interfaces. Motivation Sometimes a toolkit class thats designed for reuse isnt reusable only because its interface doesnt 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
文档评论(0)