ITPub博客

首页 > IT职业 > IT生活 > Factory pattern

Factory pattern

原创 IT生活 作者:ilovesimple2006 时间:2007-08-22 14:55:24 0 删除 编辑

Factory objects have several advantages:

  • Separate the responsibility of complex creation into cohesive helper objects.

  • Hide potentially complex creation logic.

  • Allow introduction of performance-enhancing memory management strategies, such as object caching or recycling.

Name:

Factory

Problem:

Who should be responsible for creating objects when there are special considerations, such as complex creation logic, a desire to separate the creation responsibilities for better cohesion, and so forth?

Solution: (advice)

Create a Pure Fabrication object called a Factory that handles the creation.

It's always used with Singleton pattern.

[@more@]

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/792140/viewspace-964967/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: GRASP
下一篇: 没有了~
请登录后发表评论 登录
全部评论
  • 博文量
    16
  • 访问量
    7122