
What
is the need for Abstract Factory
|
Plant class can have different derived classes to denote different plants like Broccoli, Peas, Pomogranate and so on. Now each derived class of Garden will have a different set of Plant instances within it. For example, FruitsOnlyGarden will contain Plants derived classes namely Pomogranate, Apple, Mango. Similarly VegOnlyGarden will contain Plants derived classes namely Broccoli, Peas, Spinach.
Deciding which derived class of Garden has to be instantiated (which in turn decides which all derived classes of Plant have to be instantiated) is done by a method implementing Abstract Factory Pattern.
You are also
permitted to use Simple Factory Pattern inside Abstract Factory Pattern.
In this scenario, deciding which all derived classes of Plant have to
be created inside the instance of Garden can be done using Simple Factory
Pattern.
_______________________________________________________________________
FREE Subscription
Subscribe
to our mailing list and receive new articles
through email. Keep yourself updated with latest
developments in the industry.
Note
: We never rent, trade, or sell my email lists to
anyone.
We assure that your privacy is respected
and protected.
Visit .NET Programming Tutorial Homepage
______________________________________________________