John E:
I like the DI, but have a little visceral reaction to having the DI framework mess with your objects directly rather than having something passed in or maybe a single object that is populated with a value. For example, having something like "this.injector.myUserModel" rather than "this.myUserModel". It just seems very easy to have field or method name conflicts.
Dave C:
I felt conflicted about this, myself. But I thought that by declaring the injected variables right at the top of the file, it would be very clear which properties are expected to be injected. Furthermore if we have a convention of descriptive variable names, like "quoteModel" I see it hard for there to be a conflict with a local variable. Let's discuss more though...
To argue both sides of this point (and to contradict my earlier argument), perhaps when injection occurs, we could overwrite the declared "injections" array (which is only used once to declare what the injection names are) with an injections map that maps each injection name to the injected object instance.
This would serve to clean up a superfluous array, and would be safer to use without the worry about variable name conflicts.
I only worry about the verbosity of using this.injections.quoteModel... On the other hand it makes it very easy to tell which objects came from injections...
John E:
If it's just the verbosity, then a must shorter name could be used (e.g. this.gi.quoteModel) where gi stands for Geppetto Injector or something like that.
John E:
Dave C:
John E: