© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2022
D. NesterukDesign Patterns in .NET 6https://doi.org/10.1007/978-1-4842-8245-8_4

4. Factories

Dmitri Nesteruk1  
(1)
St. Petersburg, c.St-Petersburg, Russia
 

I had a problem and tried to use Java. Now I have a ProblemFactory.

Old Java joke

This chapter covers two GoF patterns: Factory Method and Abstract Factory. These patterns are closely related, so we’ll discuss them together. The truth, though, is that the real design pattern is called Factory and that both Factory Method and Abstract Factory are simply variations that are important, but certainly not as important as the main thing.

Scenario

Let’s begin with a motivating example. Suppose you want to store information ...

Get Design Patterns in .NET 6: Reusable Approaches in C# and F# for Object-Oriented Software Design 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.