Comment #10 on issue 658 by [email protected]: Make it clear how to do an optional Injector.getInstance
http://code.google.com/p/google-guice/issues/detail?id=658

Sam, if you would be willing to accept either the javadoc addition or an extension module, could you please reopen this issue? I cannot.

Remaining remarks:

I also think getInstance should be used as sparingly as possible, since you're adding a direct dependency to the Guice API rather than rely on the standard annotations (which provide looser coupling)

Let's break this argument into two pieces:

- "standard": That might hold if I used @javax.inject.Inject, but @com.google.inject.Inject seems to be preferred at Google.

- "looser coupling": It's worth noting that this is not unambiguously a good thing, but rather the same trade-off as using Guice in general: looser coupling via behind-the-scenes action for weaker static verification and poorer code understandability (at least until the IDEs catch up).

getInstance is, at it's best, the last resort to do what you need, but 99% of the time, it's the wrong thing and indicative of some poor design.

I'll buy that. My concern is for the 1%, and for cases like mine where the better design has been identified but I don't want to block my current work on that cleanup.

--
You received this message because you are subscribed to the Google Groups 
"google-guice-dev" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-guice-dev?hl=en.

Reply via email to