lundi 9 décembre 2019

Difference between a global variable and an injected variable?

Is it common practice to communicate via field references. Let's say I have an instance injected all over my program. Since all classes are referencing the same instance I can simply change it's state, instead of informing all dependent classes via method calls? Isn't that a big advantage of dependency injection? Or do I turn a dependency injected variable turn into a global variable?

Aucun commentaire:

Enregistrer un commentaire