DEV Community

Discussion on: An IoC pattern to avoid repetitive if statements

Collapse
 
tomazfernandes profile image
Tomaz Lemos

That's a fairly good point. Without DI this class would probably indeed have the responsibility of instantiating those classes, but the DI pattern we're using implies the instances will be instantiated somewhere else (Spring's container, for instance) and injected through the constructor.

Thread Thread
 
tomazfernandes profile image
Tomaz Lemos

Maybe we could have the DataHandlerSelector, and then a DataHandlerSelectorFactory to do the actual instantiation of all the classes involved, I guess it would be more accurate.