博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Design Pattern----Creational.Pattern
阅读量:4563 次
发布时间:2019-06-08

本文共 2497 字,大约阅读时间需要 8 分钟。

Creational patterns

In software engineering, creational design patterns are design patterns that deal with object creation mechanisms, trying to create objects in a manner suitable to the situation. The basic form of object creation could result in design problems or added complexity to the design. Creational design patterns solve this problem by somehow controlling this object creation.

Example of Abstract Factory

  • Creates an instance of several families of classes
  • Separates object construction from its representation
  • Creates an instance of several derived classes
  • Avoid expensive acquisition and release of resources by recycling objects that are no longer in use
  • A fully initialized instance to be copied or cloned
  • A class of which only a single instance can exist

Rules of thumb

  1. Sometimes creational patterns are competitors: there are cases when either or could be used profitably. At other times they are complementory: might store a set of from which to clone and return product objects, can use one of the other patterns to implement which components get built. , , and can use in their implementation.
  2. , , and define a factory object that’s responsible for knowing and creating the class of product objects, and make it a parameter of the system. has the factory object producing objects of several classes. has the factory object building a complex product incrementally using a correspondingly complex protocol. has the factory object (aka prototype) building a product by copying a prototype object.
  3. classes are often implemented with s, but they can also be implemented using .
  4. can be used as an alternative to to hide platform-specific classes.
  5. focuses on constructing a complex object step by step. emphasizes a family of product objects (either simple or complex). returns the product as a final step, but as far as the is concerned, the product gets returned immediately.
  6. is to creation as is to algorithm.
  7. often builds a .
  8. s are usually called within s.
  9. : creation through inheritance. : creation through delegation.
  10. Often, designs start out using (less complicated, more customizable, subclasses proliferate) and evolve toward , , or (more flexible, more complex) as the designer discovers where more flexibility is needed.
  11. doesn’t require subclassing, but it does require an Initialize operation. requires subclassing, but doesn’t require Initialize.
  12. Designs that make heavy use of the and patterns often can benefit from as well.

转载于:https://www.cnblogs.com/xiuyusoft/archive/2011/06/16/2097567.html

你可能感兴趣的文章
计数(count)
查看>>
cruise-control
查看>>
js 常用页面刷新
查看>>
HBase-TDG ClientAPI Advanced Features
查看>>
运行php程序时,浏览器跳出打开和保存提示框
查看>>
Scrapy图片下载,自定义图片名字
查看>>
熟悉常用的HBase操作
查看>>
Github入门教程
查看>>
java枚举使用详解(转)
查看>>
我设计的简单事务控制 (转贴自:http://www.cnblogs.com/dannyr)
查看>>
Linux系统学习
查看>>
ELK-5.4.1搭建日志管理系统(二)ES安装时遇到的一些问题
查看>>
设计模式——装饰器
查看>>
Hadoop 使用基础
查看>>
对于软件的点评
查看>>
pwd 命令总结
查看>>
node.js富文本编辑器
查看>>
区间DP入门题目合集
查看>>
给定一个字符串,验证它是否是回文串,只考虑字母和数字字符,可以忽略字母的大小写。输入: "A man, a plan, a canal: Panama" 输出: true...
查看>>
Basic4android v2.70 发布
查看>>