DEV Community

Discussion on: An IoC pattern to avoid repetitive if statements

Collapse
 
wrldwzrd89 profile image
Eric Ahnell

I like this idea a lot, effectively, you're registering, iterating and picking with a lot less overhead / boilerplate. You can call it a lot of things - it is a form of dependency injection, though not the one I'm used to - but it's definitely a way to clean up what would otherwise be a tangled knot of logic. I approve!

Collapse
 
tomazfernandes profile image
Tomaz Lemos

Hi Eric, I’m really glad you liked it!

Yeah, I’ve always thought of this pattern as a kind of factory in that it provides a specific implementation based on a parameter, but it does lack the characteristic of instantiating the classes which is the basis for a factory, so I guess we’ll have to come up with a better name!

Thanks a lot for your support!