I have a SocketManager
class that contains a Socket
and other fields. All fields except the Socket
can be injected during the composition of the object graph with a DI framework. My idea was to simply build the entire object graph upfront by leaving Socket
empty and set it during runtime. This would allow me to complete the SocketManager
instantiation at one point in the code and use that instance throughout my entire program (as it was already set as an dependency through the DI framework)? Is that the standard way to "inject" runtime dependencies or is it bad practice?
A abstract factory seems to be a bad idea for two reasons: a) it creates a different object everytime b) It requires the runtime parameters at every place where I want to create the object
mardi 25 septembre 2018
Is it a bad practice to set dependencies to NULL in a IoC container and supply the dependencies at runtime?
Inscription à :
Publier les commentaires (Atom)
Aucun commentaire:
Enregistrer un commentaire