Skip to content

Latest commit

 

History

History
14 lines (9 loc) · 1013 Bytes

Factory Method.md

File metadata and controls

14 lines (9 loc) · 1013 Bytes

Overview:

A Factory method allows you to construct the object. It can be useful for many different reasons like returning a cached instance, subclassing, loose coupling, etc. Using a Factory Method will depend on the circumstance in which your object needs to be constructed.

Types participating in this pattern include:

  • Star
    • is a class that contains two different Factory Methods, both of which can construct and return an instance of the containing class. The Client facing data is privatized, and the constuctor is also privatized reducing the possibility that someone can access it. Additionally it has an ToString() method override, to help show if the class was initialized or not.

Sources:

Design Patterns in C# and .NET - Factory: Factory Method

image