DesignPattern【DOC精选】.docVIP

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

创建性模式 Abstract Factory(抽象工厂): 对于一个系统中需要用到不同的产品家族,而在某一时刻仅用到其中的一个家族的产品时,Abstract factory是个合适的选择。它可以提供客户端与具体产品之间的耦合,隐藏具体产品的实现细节,从而使更换产品家族变得容易。但是有一个缺点,就是如果增加新的产品类型变得困难,因为需要修改AbstractFactory接口以及所有相关子类。 Builder(生成器): 把复杂对象的创建和他的表示分离,这样同样的创建过程可以创建不同的表示。 Factory method(工厂方法): 对于每一个具体的Product有一个对应的Creator来创建它。也可一使用参数化的工厂方法来创建所有的Product而不用对每一个ConcreteProduct创建一个Creator类。经常和动态类装入器组合在一起应用 工厂方法和抽象工厂有一定的相似:都是通过工厂来创建Product。但是在Abstract Factory中有多个产品类型,并且这些产品类型之间相关。 Prototype(原型) 原型和工厂的共同点和差异? 应用场合: 要实例化的类是在运行时刻指定,例如动态加载 为了避免和工厂方法一样创建和产品类平行的工厂类; 一个类的实例只有几个状态。 如果使用中原型较多,最好使用原型管理器 Singleton(单件) 保证一个类只有一个实例,并提供一个全局访问点。 结构性模式 Adapter(适配器) 通过多重继承适配 通过对象复合适配。 Bridge(桥接) Use the Bridge pattern when you want to avoid a permanent binding between an abstraction and its implementation. This might be the case, for example, when the implementation must be selected or switched at run-time. both the abstractions and their implementations should be extensible by subclassing. In this case, the Bridge pattern lets you combine the different abstractions and implementations and extend them independently. changes in the implementation of an abstraction should have no impact on clients; that is, their code should not have to be recompiled. (C++) you want to hide the implementation of an abstraction completely from clients. In C++ the representation of a class is visible in the class interface. you have a proliferation of classes as shown earlier in the first Motivation diagram. Such a class hierarchy indicates the need for splitting an object into two parts. Rumbaugh uses the term nested generalizations?[RBP+91] to refer to such class hierarchies. you want to share an implementation among multiple objects (perhaps using reference counting), and this fact should be hidden from the client. A simple example is Copliens String class?[Cop92], in which multiple objects can share the same string representation (StringRep). Composite(组合) 当表示整体部分结构并且需要嵌套结构时可以使用组合模式。 Decorator

文档评论(0)

taotao0b + 关注
实名认证
文档贡献者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档