Factory Design Pattern Analogue(原创)

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.




Factory Design Pattern Analogue(原创)_第1张图片
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.
 

 Factory Design Pattern Analogue(原创)_第2张图片

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?

你可能感兴趣的:(Pattern,design)