What is the need for Abstract Factory Pattern in C#?
Factory Pattern has a higher level of abstraction when compared to the
Factory Method Pattern. You will be using Abstract Factory Pattern when
you should return one among several set of classes that are related.
To illustrate on it, consider the following scenario: Your application has a base class called Garden which contains multiple instances of Plant class to show what all plants are planted in the Garden. Garden class is further drilled down into different derived classes namely VegOnlyGarden, FruitsOnlyGarden, MixedGarden and so on.
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
to our mailing list and receive new articles Note
: We never rent, trade, or sell my email lists to Visit
.NET Programming Tutorial Homepage ______________________________________________________
to our mailing list and receive new articles
: We never rent, trade, or sell my email lists to
Visit .NET Programming Tutorial Homepage
| Can you call a constructor from another constructor of the Class in .NET? | Difference between Response.Output.Write() method and Response.Write() method in .NET | How do you establish multiple inheritance in C#? | How do you introduce a ReadOnly property in C#? | How do you perform constructor overloading in C#? | Is catch(Exception) recommended to be used in .NET? | What are the different access modifiers available in C#? | What are the different ways of overloading in C#? | What are the members of stringbuilder class in C#? | What is Multicast Delegate? Explain it with example in C# | What is the difference between abstract class and interface in .NET? | What is the difference between Clone and CopyTo methods in .NET | What is the difference between const and readonly in .NET | What is the difference between directcast and ctype in .NET? | What is the difference between out and ref parameters in .NET | What is the difference between public assembly and private assembly in .NET | What is the difference between strong typing and weak typing in .NET? | What is the difference between Trace and Debug in .NET | What is the need for Abstract Factory Pattern in C#? | What is the need for Adapter Pattern in C# |
Amazon and the Amazon logo are trademarks of Amazon.com, Inc. or its affiliates.
Copyright - © 2004 - 2023 - All Rights Reserved.