On 24 Nov 2013, at 11:38, David Hoffer wrote:
IMHO, one shouldn't need the use/existence of a code framework (e.g.
Guice)
to show intent. The Java language/syntax provides that very clearly
and
simply using constructor injection. I concur with Sam that objects
should
not be constructed without all their dependencies.
It's not a "code framework" it's a JSR spec. JSR-330. And it is
entirely suitable for indicating that this class expects its
dependencies to be satisfied from the outside. That is entirely the
point of the spec. It can be done using Guice, or Dagger, or Spring, or
your own hand-rolled code, or a Fake or a Mock. You see what I mean?
I'm not disagreeing that constructor injection is semantically clear and
precise, etc. I prefer the semantic guarantees of constructor
injection. But it is also verbose boiler-plate. Whether it's worthwhile
boiler plate is a trade-off decision rational developers must make, and
development is about trade-offs and expected pay-offs for costs. Costs
to readability and clarity result in long-term maintenance costs, and
introduction of error because the code is harder to reason through.
Semantic purity reduces error on a different kind of dimension. Please
choose what your project finds appropriate.
But please do not suggest that a java standard set of annotations, whose
goal is to provide specific semantic meaning to frameworks and humans
reading the intent and needs of the code, are something one "shouldn't"
need. That's a judgment about design choices you simply can't make in
place for other teams and projects.
cheers,
Christian.
Christian Gruber :: Google, Inc. :: Java Core Libraries :: Dependency
Injection
email: [email protected] :::: mobile: +1 (646) 807-9839
--
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice.
For more options, visit https://groups.google.com/groups/opt_out.