Tuesday, March 28, 2017

onion-breaking antipattern

You can auto hydrate IoC dependencies at class constructors and not just the constructors of MVC5 controllers it seems. I don't recommend it. If you are getting the dependencies at controllers and handing them on to core logic, if you are not exclusively using the UI at a bootstrapper but are wiring up dependencies at the core logic or infrastructure projects, you are opening the door to trouble. Do all IoC wireup at the UI and hand them down to core logic which should know nothing more than "oh, I'm getting an interface at a method signature" In a scenario wherein a controller calls out to a manager (bad name) in a core project and then that calls a repository in the infrastructure project, only the controller should have a signature where IoC magic takes place via StructureMap.

No comments:

Post a Comment