DEV Community

Discussion on: How to avoid the Factory pattern in C#

Collapse
 
thatblairguy profile image
That Blair Guy

The examples for conveying a concept are rarely effective at showing the power of the concept. (E.g. A factory that simply wraps new MyType();).

And the examples that show how powerful a concept can be (e.g. A factory that demonstrates the provider/strategy pattern) is rarely effective for demonstrating the concept of a factory at its purest level.

My own experience is that simple factories aren't good for much except demonstrating what a factory is. But factories tend to be where the "magic" part of a design pattern is implemented. (Strategy, Decorator, and even Visitor, are all built on Factory.)

Thread Thread
 
shimmer profile image
Brian Berns • Edited

I think we’re in agreement that factories are useful. My only point is that modern C# can accomplish the same thing using functional programming instead of OO classes.

(The GoF book was written before mainstream OO languages supported functional programming.)