Matt Can Code  
公告
日历
统计
  • 随笔 - 12
  • 文章 - 0
  • 评论 - 19
  • 引用 - 1

导航

 

Factory Design Pattern(FDP) is comparatively small in granularity than either Simple Factory or Abstract Factory, one kind of

factory produce one and only one kind of production.

The abstract of FDP is to let the subtype of factory decide the particular type of its production.
Usually you may see kind of parallel evolution in types both in factories and productions.

Here is a analogue in real life that I have conceived in my head for so long that can describe this Design Pattern. a Mother can produce a baby, this is a common sense, so I am analogizing mother as a factory(by no means an insult to a mother), a specified kind of mother can produce a specified kind of baby, a more specified kind of mother can produce a more specified kind of baby.





Actually a mother who can give birth to a baby boy can also give birth to a baby girl, FURTHER MORE, mother who create children of special type that can and only can interact with their counterpart, for example, korean girl can and only can play with korean boy, this is when Abstract Factory comes into play.
 

 

In the early blog issue 典型的组合模式和迭代器, iterator is also a product which is produced by Factories like ArrayList,  SortedList, Collection and consumed by the client who has the access to the Factory and the product, and the product in this special case encapsulated the data structure of the Factory, pretty much a hybrid of Bridge and Factory.Do you agree?

posted on 2007-02-26 15:22 Matt Yeung 阅读(61) 评论(0) 编辑 收藏
 
Copyright © Matt Yeung Powered by: 博客园 模板提供:沪江博客