samedi 14 mars 2015

Where should be a property injected?

Reading the book of Mark Seemann - Dependency Injection in .NET made me think more about implementing his concepts, but also observing some missing parts.

He specifies pretty everywhere aspects about constructor injection and where this should take place, and how , but he speaks so little about the injection time of a property.



If only the Composition Root should be my only entrance point which
knows all my dependencies, then where should a property be set to the
new dependency (because a local default is mandatory)?


If I do that right away in the CR then what's the point of a local default?



So, in order to use the Property Injection pattern the right way,
am i constrained to assign only implementations from the same assembly
which can be anywhere outside the Composition Root?


This of course can lead to fuzzy waters making me wonder if an interface property can be overall still helpful?



If the main purpose of an abstract property is to allow Strategies
(design pattern) then probably I am better of with an Abstract Factory
injected eventually also in my constructor?

Aucun commentaire:

Enregistrer un commentaire