DEV Community

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

Collapse
thfsilvab profile image
Thadeu

But, what if I'm building a Beagle and a German Shepherd?

I'd make sense to have two classes that build the same class Dog, but gives me a different ones, based on it's properties.

More code? You're right, but also much more readable.

Collapse
shimmer profile image
Brian Berns Author • Edited

I'm not sure I follow you. Are you saying that we could create Beagle and GermanShepherd as subclasses of Dog? That's true, but I don't see how that would change the situation much.

Can you clarify, or give an example where a factory class makes more sense than a function?