Factory Design Pattern analogue (original)

Source: Internet
Author: User

Factory Design Pattern (FDP) is comparatively small in granularity than either simple factory or abstract factory, one kind

Factory produce one and only one kind of production.

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

Here is a analog 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 typical combination mode and iterator, 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?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.