© Vaskaran Sarcar 2020
V. SarcarDesign Patterns in C#https://doi.org/10.1007/978-1-4842-6062-3_4

4. Factory Method Pattern

Vaskaran Sarcar1 
(1)
Garia, Kolkata, West Bengal, India
 

This chapter covers the Factory Method pattern.

Note

To better understand this pattern, I suggest you first read Chapter 24, which covers the Simple Factory pattern. The Simple Factory pattern does not fall directly into the Gang of Four design patterns, so it appears in Part II of the book; however, the Factory Method pattern will make more sense if you first understand the pros and cons of the Simple Factory pattern.

GoF Definition

Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation ...

Get Design Patterns in C#: A Hands-on Guide with Real-world Examples now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.