What is a factory pattern? how do you implement it?

  • Factory Method is one of the 23 design patterns.
  • It is a creational pattern, meaning it describes the best way of instantiating a class based on an input varying condition.
  • Factory method helps in deciding which instance of a class needs to be supplied based on an input condition which is resolved during runtime.
  • It helps in creating loosely-coupled applications where the choice of functionality can be switched during runtime.
  • It states that - "just define an interface or abstract class for creating an object but let the subclasses decide which class to instantiate"

Exploring Design Patterns - Factory Method

C# Concepts Posted May 14, 2021

You can now show your support. 😊

We use cookies to provide you with a great user experience, analyze traffic and serve targeted promotions.   Learn More   Accept