开发者

how does Abstract Factory design pattern is useful ? doesn't it just a polymorphism and nothing else ? [closed]

开发者 https://www.devze.com 2023-03-24 07:36 出处:网络
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references,or expertise, but this question will likely solicit debate, a
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 11 years ago.

how does Abstract Factory is useful ? doesn't it just a polymorphism and nothing else ?

I have read all the design patterns and everywhere things looks similar. most of them are开发者_StackOverflow社区 type of polymorphism's different flavors.


Abstract Factory uses polymorphism, yes, but so do many other patterns - polymorphism is a fundamental part of object oriented languages, so it is also part of how you express concepts in individual patterns.

The core of this design pattern is to be able to switch out a family of related class hierarchies (as opposed to individual types) by introducing an abstract factory to encapsulate object creation for all types within the family.

Once you provide a concrete implementation of the abstract factory for a particular "family" (or "theme"), this factory then in turn is used to create instances of classes within the family - the prime example being platform dependent widgets.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号