TL;DR — Intent and the Core Trade-off
Intent, in one sentence: define a method for creating an object, but let the classes that use it defer the actual choice of concrete type to a subclass (or, in modern practice, to a delegate or DI registration) instead of hard-coding new ConcreteThing() everywhere it's needed.
The single rule that defines the pattern: the code that calls the factory method never mentions a concrete product type by name. If a caller writes new SomeConcreteProduct() anywhere near the "factory," the pattern has already been defeated — the whole point is that the decision lives in exactly one place, and everything else programs against the abstraction.
What you buy: new product types can be introduced without touching the code that consumes them — you add a class and, at most, one registration line.
What you pay: an extra layer of indirection and, in its classic inheritance-based form, an extra class per product (one for the product, one for the creator that builds it). In a language with generics, delegates, and a DI container, a good chunk of that cost is now optional — which is exactly the live argument covered in §6 and §12.
Factory Method is the most misunderstood of the five Creational patterns because "factory" gets used loosely for three different things: a bare static method that returns different types based on a parameter (often called Simple Factory and not actually a GoF pattern), the true Factory Method (an overridable creation point tied to a class hierarchy), and Abstract Factory (a family of related factory methods grouped behind one interface). This document is about the middle one — and is explicit, throughout, about where it stops and the other two begin.
Origins, Classification, and the Problem It Solves
Classification: Creational, class-scoped (its variation point is inheritance — a subclass overriding a method — rather than an object reference swapped at runtime, which is what makes it structurally different from Strategy despite the similar UML shape). First catalogued in Design Patterns: Elements of Reusable Object-Oriented Software (Gamma, Helm, Johnson, Vlissides), 1994.
It was a reaction to a specific 1994-era C++ and Smalltalk problem: frameworks that wanted to be extensible had no good way to let application code plug in its own object types at the exact point where the framework needed to create something. A drawing framework's Application class needs to create a Document, but the framework author has no idea whether the application wants a TextDocument or a SpreadsheetDocument. Constructors can't be overridden the way methods can, so GoF's answer was: wrap the construction in an ordinary virtual method, and let the subclass override that instead.
The "before" code — the mess this pattern removes
Here's the shape almost everyone has actually written: a method that grows a new if/switch branch every time the business adds a new document export format.
// Reports/ReportExporter.cs — the mess, before Factory Method
public sealed class ReportExporter
{
public IReportWriter CreateWriter(string format)
{
// Every new format means opening this method and adding a branch.
// Every branch means ReportExporter must know the constructor
// signature of every writer that has ever existed.
switch (format)
{
case "pdf":
return new PdfReportWriter(new PdfEngine(), compress: true);
case "csv":
return new CsvReportWriter(includeHeaders: true);
case "xlsx":
return new ExcelReportWriter(new WorkbookFactory(), "Sheet1");
case "html":
return new HtmlReportWriter(inlineStyles: true);
// ...six sprints later, eight more cases, three of them
// subtly wrong because nobody remembered the PDF branch
// needed `compress: true` when they copy-pasted a new one.
default:
throw new NotSupportedException($"Unknown format: {format}");
}
}
}
The real pain isn't the length of the switch — it's that ReportExporter now has a compile-time dependency on every writer's constructor, so it must be recompiled and redeployed for a format it doesn't otherwise care about, and every caller of CreateWriter is exposed to that churn through the string parameter's silently expanding contract.
Structure and Participants
| Participant | Role | Belongs in it | Must never be in it |
|---|---|---|---|
Product | The common interface every created object honours | Only members every concrete product can genuinely implement | Members only one concrete product needs — that's a leaky abstraction |
ConcreteProduct | One buildable variant | The behaviour specific to that variant | Knowledge of which Creator built it |
Creator | Declares the factory method and uses its result via Product only | The workflow/business logic that uses the product (AnOperation) | A switch over concrete product types — that's the anti-pattern in §14 |
ConcreteCreator | Overrides the factory method to return one specific product | Exactly one new ConcreteProductX() call and nothing else | Business logic — that belongs in the base Creator, shared |
The membership test: a class is a genuine ConcreteCreator only if the only thing it overrides is the creation decision — if it's also overriding or duplicating business logic from the base Creator, it's not specializing construction, it's forking behaviour, and the pattern has drifted into template-method territory without saying so.
The Central Mechanic
The trick is narrower than people expect: the Creator base class calls its own factory method, through itself, without knowing which override will run. That's ordinary virtual dispatch — nothing exotic — but the payoff is that Creator.AnOperation() can be written once, fully generic over the product type, and never touched again as new products appear.
// Reports/ReportExporter.cs — the mechanic, smallest possible form
public abstract class ReportExporter
{
// The factory method: overridable, returns the abstraction only.
protected abstract IReportWriter CreateWriter();
// Shared workflow, written once, never touched when a format is added.
public byte[] Export(ReportData data)
{
IReportWriter writer = CreateWriter(); // <-- the mechanic
writer.Open();
writer.Write(data);
return writer.Close();
}
}
public sealed class PdfReportExporter : ReportExporter
{
protected override IReportWriter CreateWriter() => new PdfReportWriter();
}
Step through it
Implementation in C# — Naive, Then Idiomatic
Pass one: the textbook translation
// Reports/IReportWriter.cs
public interface IReportWriter
{
void Open();
void Write(ReportData data);
byte[] Close();
}
// Reports/ReportExporter.cs — literal GoF translation
public abstract class ReportExporter
{
protected abstract IReportWriter CreateWriter();
public byte[] Export(ReportData data)
{
IReportWriter writer = this.CreateWriter();
writer.Open();
writer.Write(data);
return writer.Close();
}
}
public class PdfReportExporter : ReportExporter
{
protected override IReportWriter CreateWriter()
{
return new PdfReportWriter();
}
}
public class CsvReportExporter : ReportExporter
{
protected override IReportWriter CreateWriter()
{
return new CsvReportWriter();
}
}
This is deliberately unambitious C#: no primary constructors, no records, explicit access modifiers everywhere. It compiles and works, and it costs one extra class per format — the thing critics point at first (§12).
Pass two: what a .NET 10 developer actually writes in 2026
// Reports/ReportExporter.cs — idiomatic .NET 10 / C# 14
namespace Reports;
public abstract class ReportExporter
{
// Factory method stays abstract — the variation point is unchanged.
protected abstract IReportWriter CreateWriter();
public async Task<byte[]> ExportAsync(ReportData data, CancellationToken ct = default)
{
IReportWriter writer = CreateWriter();
await writer.OpenAsync(ct);
await writer.WriteAsync(data, ct);
return await writer.CloseAsync(ct);
}
}
// A required member + sealed-by-default concrete creator — no ceremony
// beyond the one thing this class actually decides.
public sealed class PdfReportExporter(PdfEngineOptions options) : ReportExporter
{
protected override IReportWriter CreateWriter() => new PdfReportWriter(options);
}
public sealed class CsvReportExporter : ReportExporter
{
protected override IReportWriter CreateWriter() => new CsvReportWriter();
}
// Registered by format key — no switch statement anywhere, ever.
// Program.cs
builder.Services.AddKeyedTransient<ReportExporter, PdfReportExporter>("pdf");
builder.Services.AddKeyedTransient<ReportExporter, CsvReportExporter>("csv");
builder.Services.AddKeyedTransient<ReportExporter, ExcelReportExporter>("xlsx");
| Divergence | Naive cost | Why the idiomatic version wins here specifically |
|---|---|---|
Primary constructor on PdfReportExporter | Hand-written constructor + field assignment boilerplate | The concrete creator's only job is holding what it needs to build one product — a primary constructor says exactly that, nothing more |
sealed by default | Open to further inheritance nobody asked for | A ConcreteCreator is a leaf in this hierarchy by design; leaving it open invites a second override point that muddies which class decides what |
async I/O | Synchronous writer calls block a thread per export | Every real writer touches a stream, a file, or a network call — a 2026 sample that pretends otherwise teaches a bad default |
| Keyed DI registration instead of a switch | A dictionary or switch mapping strings to types, hand-maintained | The container already knows how to hold a keyed table of implementations — reinventing it duplicates behaviour .NET ships for free |
Variations and Modern .NET Idioms
| Variation | Shape | When it's the better fit |
|---|---|---|
| Classic inheritance | Abstract Creator, one subclass per product | The Creator has substantial shared workflow logic beyond just creating the product — subclassing carries real weight |
Func<Product> delegate | Creator takes a factory delegate in its constructor instead of declaring an abstract method | The "creator" has no other behavior worth subclassing for — a delegate is a factory method without the ceremony of a type hierarchy |
| Keyed DI services | IServiceProvider.GetRequiredKeyedService<T>(key) resolves the product by a runtime key | The product set is configured, not compiled — new formats are added via container registration, not new source files |
| Parameterized static method ("Simple Factory") | One static method with a switch — not actually GoF Factory Method | Genuinely small, closed, unlikely-to-grow product sets; call it what it is rather than dressing it up as the pattern |
// The delegate variation: same intent, no type hierarchy at all.
public sealed class ReportExporter(Func<IReportWriter> createWriter)
{
public async Task<byte[]> ExportAsync(ReportData data, CancellationToken ct = default)
{
IReportWriter writer = createWriter();
await writer.OpenAsync(ct);
await writer.WriteAsync(data, ct);
return await writer.CloseAsync(ct);
}
}
// Usage — the "factory method" is now just a lambda passed at construction.
var pdfExporter = new ReportExporter(() => new PdfReportWriter(options));
Say it plainly: for a single, unshared creation decision, the delegate form is the modern default in C#. A first-class function type absorbed the ceremony that used to require a subclass. The inheritance-based classic form is now reserved for the case §12 keeps circling back to — where the Creator carries enough shared, overridable workflow that a subclass is pulling its weight for reasons beyond construction.
// The keyed-DI variation resolved by runtime data, not a compiled type choice.
public sealed class ReportExportEndpoint(IServiceProvider services)
{
public async Task<byte[]> ExportAsync(string format, ReportData data, CancellationToken ct)
{
var exporter = services.GetRequiredKeyedService<ReportExporter>(format);
return await exporter.ExportAsync(data, ct);
}
}
Where .NET Itself Uses It
| BCL / ASP.NET Core type | Factory method role |
|---|---|
Stream.CanRead / WebRequest.Create(Uri) | WebRequest.Create is a textbook Factory Method — the static entry point returns different concrete request types (historically HttpWebRequest, FileWebRequest) based on the URI scheme, resolved through a registered creator per scheme |
HttpMessageHandlerBuilder / IHttpClientFactory.CreateClient(name) | The named client is the "product"; the factory method is CreateClient, and different registrations act like different ConcreteCreators selected by name |
DbProviderFactory.CreateConnection() | Textbook Factory Method in ADO.NET — SqlClientFactory, NpgsqlFactory, etc. each override CreateConnection to return their own DbConnection subtype |
IHttpClientFactory, ILoggerFactory.CreateLogger(string) | Return an abstraction (ILogger) whose concrete type the caller never names — the calling code is coded entirely against the interface |
// ILoggerFactory.CreateLogger is a Factory Method the BCL ships:
// the caller never knows or cares which ILogger implementation comes back.
public sealed class OrderService(ILoggerFactory loggerFactory)
{
private readonly ILogger<OrderService> _log = loggerFactory.CreateLogger<OrderService>();
public void Place(Order order)
{
_log.LogInformation("Placing order {OrderId}", order.Id);
}
}
// DbProviderFactory: the actual GoF shape, alive in ADO.NET today.
DbProviderFactory factory = DbProviderFactories.GetFactory("Npgsql");
using DbConnection connection = factory.CreateConnection()!; // <-- factory method
connection.ConnectionString = config.GetConnectionString("Orders");
Worth flagging honestly: DbProviderFactory is the purest textbook example left in the BCL, but most new code reaches for a strongly-typed provider package (Npgsql, Microsoft.Data.SqlClient) directly rather than going through the abstract factory — provider-agnostic ADO.NET code is rarer in practice than the pattern's textbook fame suggests.
// IHttpClientFactory.CreateClient(name) — another BCL Factory Method:
// the concrete HttpClient configuration behind "orders-api" is never
// named at the call site.
public sealed class OrdersApiClient(IHttpClientFactory httpClientFactory)
{
public async Task<Order?> GetOrderAsync(int id, CancellationToken ct)
{
using HttpClient client = httpClientFactory.CreateClient("orders-api");
return await client.GetFromJsonAsync<Order>($"/orders/{id}", ct);
}
}
Runtime Flows
Happy path
Failure path — the factory method itself throws
A structurally interesting path — swapping the creator behind an interface at startup
Real-World Worked Examples — Three
1. Notification channel creation (notifications domain)
A platform sends order updates over email, SMS, or push, and needs to add channels over time without editing a dispatcher every time.
// Notifications/NotificationDispatcher.cs
public abstract class NotificationDispatcher
{
protected abstract INotificationChannel CreateChannel();
public async Task SendAsync(NotificationMessage msg, CancellationToken ct)
{
INotificationChannel channel = CreateChannel();
await channel.SendAsync(msg, ct);
}
}
public sealed class EmailNotificationDispatcher(IEmailClient client) : NotificationDispatcher
{
protected override INotificationChannel CreateChannel() => new EmailChannel(client);
}
public sealed class SmsNotificationDispatcher(ISmsGateway gateway) : NotificationDispatcher
{
protected override INotificationChannel CreateChannel() => new SmsChannel(gateway);
}
2. Payment processor selection (payments domain)
An e-commerce backend must build the correct payment gateway client for the merchant's configured provider.
// Payments/PaymentCheckout.cs
public abstract class PaymentCheckout
{
protected abstract IPaymentProcessor CreateProcessor();
public async Task<PaymentResult> ChargeAsync(Order order, CancellationToken ct)
{
IPaymentProcessor processor = CreateProcessor();
return await processor.ChargeAsync(order.Total, order.Currency, ct);
}
}
public sealed class StripeCheckout(StripeOptions options) : PaymentCheckout
{
protected override IPaymentProcessor CreateProcessor() => new StripeProcessor(options);
}
// Program.cs — resolved by merchant configuration, not a switch
builder.Services.AddKeyedTransient<PaymentCheckout, StripeCheckout>("stripe");
builder.Services.AddKeyedTransient<PaymentCheckout, PayPalCheckout>("paypal");
3. Device I/O — where Factory Method is an uncomfortable fit
A warehouse app talks to barcode scanners from three vendors. The temptation is a ScannerFactory hierarchy — but the vendors' SDKs differ not just in construction but in connection lifecycle, error codes, and threading model, so the "shared workflow" the base Creator is supposed to hold barely exists.
// Devices/ScannerSession.cs — the awkward-fit version
public abstract class ScannerSession
{
protected abstract IBarcodeScanner CreateScanner();
// This "shared" method ends up almost empty, because everything
// interesting — reconnect policy, timeout handling — differs per vendor
// and gets pushed back down into overrides anyway.
public async Task<string> ScanOnceAsync(CancellationToken ct)
{
IBarcodeScanner scanner = CreateScanner();
return await scanner.ReadAsync(ct);
}
}
public sealed class ZebraScannerSession(ZebraSdkOptions opts) : ScannerSession
{
protected override IBarcodeScanner CreateScanner() => new ZebraScanner(opts);
// ...but Zebra's reconnect logic needs its own override too,
// and now the "shared" base class is shared in name only.
}
This is the honest case: when the base class ends up as a thin pass-through because every vendor needs its own everything, Factory Method is providing an interface (worth keeping) without much of a workflow to share (the actual justification for the inheritance). A per-vendor adapter registered in DI, without the shared abstract base, is arguably a better fit — see §11.
// The arguably-better fit: a plain adapter behind keyed DI,
// no shared abstract Creator carrying almost nothing.
public interface IBarcodeScanner { Task<string> ReadAsync(CancellationToken ct); }
public sealed class ZebraScannerAdapter(ZebraSdkOptions opts) : IBarcodeScanner
{
public Task<string> ReadAsync(CancellationToken ct) => ZebraSdk.ReadWithRetryAsync(opts, ct);
}
builder.Services.AddKeyedSingleton<IBarcodeScanner, ZebraScannerAdapter>("zebra");
Testing Code That Uses It
Factory Method generally helps testability compared to hard-coded new calls, because the abstraction seam is already there — but it introduces its own specific pain: tests that only exercise the base Creator workflow can't verify which concrete product a given ConcreteCreator actually builds without either subclassing for the test or reaching into implementation details.
// Tests/PdfReportExporterTests.cs — xUnit
public class PdfReportExporterTests
{
[Fact]
public void CreateWriter_returns_a_PdfReportWriter()
{
// Exposing the factory method as `internal` + [InternalsVisibleTo]
// (or `protected internal` with a test subclass) is the pragmatic
// way to assert *which* concrete product came back.
var exporter = new TestablePdfReportExporter(new PdfEngineOptions());
var writer = exporter.ExposedCreateWriter();
Assert.IsType<PdfReportWriter>(writer);
}
private sealed class TestablePdfReportExporter(PdfEngineOptions options)
: PdfReportExporter(options)
{
public IReportWriter ExposedCreateWriter() => CreateWriter();
}
}
// Integration-level: verify the shared workflow end-to-end against a fake product.
public class ReportExporterWorkflowTests
{
[Fact]
public async Task ExportAsync_opens_writes_then_closes_in_order()
{
var spyWriter = new SpyReportWriter();
var exporter = new FakeReportExporter(() => spyWriter);
await exporter.ExportAsync(new ReportData());
Assert.Equal(
new[] { "Open", "Write", "Close" },
spyWriter.CallOrder);
}
private sealed class FakeReportExporter(Func<IReportWriter> factory) : ReportExporter
{
protected override IReportWriter CreateWriter() => factory();
}
}
The delegate-based variation (§6) sidesteps the "protected method" testing friction entirely — a Func<IReportWriter> passed into the constructor can be a test spy directly, with no subclassing required.
When To Use It — And When Not To
| Use it when | Don't use it when |
|---|---|
| New product types are a recurring, expected event (new export format, new payment gateway) | You have exactly two implementations and no third is plausible in the codebase's realistic lifetime |
| The Creator has meaningful shared workflow beyond just building the product | The "shared workflow" is one line — a Func<T> parameter does the whole job with less ceremony |
| A framework needs to let downstream code plug in its own types without the framework knowing about them | The variation has never actually changed in three years of the codebase's life — you're paying for flexibility nobody used |
| The product's construction genuinely differs enough per type that a switch would grow unmanageably | The indirection will be read primarily by people unfamiliar with this pattern's vocabulary, and a direct if would be more legible to them |
// "Don't use it" in practice: two fixed implementations, no third coming.
// A direct branch is more honest than a Creator hierarchy for this.
public sealed class InvoiceNumberFormatter
{
public string Format(InvoiceNumberStyle style, int number) => style switch
{
InvoiceNumberStyle.Sequential => number.ToString("D6"),
InvoiceNumberStyle.YearPrefixed => $"{DateTime.UtcNow:yyyy}-{number:D4}",
_ => throw new ArgumentOutOfRangeException(nameof(style))
};
}
Pros and Cons, Honestly
| Pros | Cons |
|---|---|
| Adding a product type never requires editing existing, working code (Open/Closed in practice) | One extra class per product in the classic form — real cost, not imagined |
| Client code is coded entirely against the abstraction — no concrete-type leakage | An extra layer of indirection a reader has to trace through to find out what's actually built |
| Plays well with frameworks: third parties can plug in types the framework author never anticipated | Static/inheritance-based — the choice of product is usually fixed once a concrete Creator is chosen, not swappable per call |
| Testable: the creation seam already exists without extra refactoring | Easy to over-apply to product sets that will never actually grow, paying complexity for flexibility that's never exercised |
Contested trade-off, stated as a disagreement: does Factory Method survive dependency injection? One camp (see Mark Seemann and Steven van Deursen's writing on DI anti-patterns) argues Abstract Factories — and by extension much of classic Factory Method — are frequently misapplied as a workaround for DI containers that can't select an implementation based on runtime data, when the actual fix is to inject the decision differently (a strategy keyed at composition time, not resolved deep inside a consumer). The counter-argument: a DI container resolves the *set* of registered types at startup, but it can't express "pick this specific one based on data only known at the point of use" without either a factory abstraction or a service locator — and a factory method is the more testable, more explicit of those two escape hatches. Both sides agree service-locator-style resolution deep inside business logic is worse than either.
Common Mistakes and Anti-Patterns
Mistake 1 — a switch statement hiding inside "the factory"
// ❌ Wrong — this "Creator" still has the exact switch it was meant to remove.
public abstract class ReportExporter
{
protected IReportWriter CreateWriter(string format) => format switch
{
"pdf" => new PdfReportWriter(),
"csv" => new CsvReportWriter(),
_ => throw new NotSupportedException(format)
};
}
// ✅ Right — the switch is gone because the decision moved to the type hierarchy.
public abstract class ReportExporter
{
protected abstract IReportWriter CreateWriter();
}
public sealed class PdfReportExporter : ReportExporter
{
protected override IReportWriter CreateWriter() => new PdfReportWriter();
}
The rationale: renaming a Simple Factory's switch to CreateWriter doesn't make it a Factory Method — the tell is whether adding a product requires editing existing code. If it does, the pattern hasn't actually been applied yet.
Mistake 2 — the base Creator reaching into concrete product state
// ❌ Wrong — Creator downcasts to reach a member Product doesn't declare.
public byte[] Export(ReportData data)
{
var writer = CreateWriter();
if (writer is PdfReportWriter pdf) pdf.SetCompressionLevel(9); // leak!
writer.Open(); writer.Write(data); return writer.Close();
}
// ✅ Right — anything every writer needs belongs on IReportWriter itself.
public interface IReportWriter
{
void Open();
void Write(ReportData data);
byte[] Close();
void Configure(WriterOptions options); // shared, not PDF-specific
}
Mistake 3 (the subtle one) — a "shared" base workflow that silently assumes one product's semantics
// ❌ Wrong — compiles, passes tests written against PdfReportExporter,
// breaks silently for a streaming writer that can't buffer everything.
public byte[] Export(ReportData data)
{
var writer = CreateWriter();
writer.Open();
writer.Write(data);
var bytes = writer.Close();
File.WriteAllBytes(TempPath, bytes); // assumes "small enough to hold in memory"
return bytes;
}
// ✅ Right — the shared method makes no assumption beyond the interface contract.
public async Task<byte[]> ExportAsync(ReportData data, CancellationToken ct)
{
var writer = CreateWriter();
await writer.OpenAsync(ct);
await writer.WriteAsync(data, ct);
return await writer.CloseAsync(ct); // caller decides what to do with the bytes
}
This one hurts six months later specifically because it works fine for every product that happens to produce small in-memory output, until a streaming export format is added and the assumption baked into the "shared" method silently corrupts or truncates its output.
Refactoring Path — Introducing It Into Existing Code
Starting from the §2 switch statement, here's an ordered path where every step ships independently and the app keeps working the whole way through.
- Cut the first seam: extract an
IReportWriterinterface from what the branches already have in common (anOpen/Write/Closeshape usually falls out immediately). No behaviour changes yet — this step is purely a signature extraction and should be a no-diff-in-behaviour commit. - Extract each branch body into its own class implementing that interface, one commit per format so a bad extraction is easy to isolate and revert.
- Introduce the abstract
Creatorwith a single abstractCreateWriter()method and the shared workflow moved onto it, still called from the same call sites via the oldReportExporter.CreateWriter(string format)entry point as a thin compatibility shim. - Move each switch branch into its own
ConcreteCreatoroverride, one at a time — existing call sites keep working because the shim still dispatches on the string. - Register the ConcreteCreators in DI, keyed by format, and change call sites one by one to resolve through the container instead of the shim.
- Delete the shim and the original switch once nothing references it — verify with a repo-wide search for the old method name before removing it.
Keeping it reviewable: land steps 1–2 as a pure-refactor PR with no behaviour change (green tests, no new registrations), then land 3–6 as a second PR that a reviewer can read purely as "wiring," since the hard part (the extraction) is already merged and stable.
| ADR field | Content for this refactor |
|---|---|
| Title | Introduce Factory Method for report writer creation |
| Status | Proposed / Accepted |
| Context | Report format selection is a growing switch statement coupling ReportExporter to every writer's constructor |
| Decision | Extract IReportWriter, introduce an abstract ReportExporter.CreateWriter(), register concrete exporters as keyed DI services |
| Consequences | New formats require one class + one registration line, not an edit to ReportExporter; adds one interface and N small classes to the codebase |
Reference Checklist
- The factory method returns the
Productabstraction, never a concrete type, from its signature. - No
switchorif-chain over concrete product types survives anywhere near "the factory." - Each
ConcreteCreatordoes exactly one thing: build and return one product type. - Shared workflow in the base
Creatormakes no assumption that holds for only some products. - Before reaching for the inheritance-based form, a
Func<T>delegate or keyed DI registration has been considered and rejected for a stated reason. - New product types can be added without editing the base
Creatoror any existingConcreteCreator. - Tests can verify which concrete product a given creator builds without reflection hacks.
- The pattern isn't applied to a product set that has never actually grown and shows no sign of needing to.
Sources
Primary
- Gamma, Helm, Johnson, Vlissides — Design Patterns: Elements of Reusable Object-Oriented Software (1994), the original Factory Method catalog entry.
Analysis and critique
- python-patterns.guide — "The Factory Method Pattern", arguing the pattern is largely an artifact of languages that can't pass classes as values.
- Seemann & van Deursen, "Abuse of Abstract Factories," Manning — the DI-era critique of over-applying factory abstractions.
- "Factory Method vs Abstract Factory — What's the Difference?" — a practical comparison of the two, useful for the §13 boundary.
.NET documentation and API references
- Microsoft Learn —
AddKeyedTransientoverloads, the keyed-DI registration shape used throughout §5–§9. - Microsoft Learn — What's new in C# 14, covering the field keyword, extension members, and null-conditional assignment referenced in §5.