Skip to content
loading...

re: How to avoid the Factory pattern in C# VIEW POST

TOP OF THREAD FULL DISCUSSION
re: I feel some anti-pattern issues: It accepts any function that returns IAnimal, not just factories. This can be risky in the long run. It decentra...
 

It accepts any function that returns IAnimal, not just factories. This can be risky in the long run.

This is no different from the factory pattern, which accepts any object that implements IAnimalFactory. I don't think there's any risk involved.

This will eventually end up writing plenty of duplicate code

I don't follow you. How does the factory pattern (or my functional version of it) lead to duplicate code? An example might help.

code of conduct - report abuse