IMHO, there's hardly ever any need to use field injection, using setters is better, but it breaks encapsulation as well. I prefer constructor injection, although it sometimes leads to long parameter list, which is awkward, especially when using inheritance.
Without constructor injection you obviously can't get your fields final and your objects immutable. On 10-07-07 14:09, Jason Winnebeck wrote: > Inability to unit test or use outside of Guice, unless you also provide > a constructor/setter (in which case the other injection methods can be > used) or break encapsulation by making the fields more visible. > > Jason > > On 7/7/2010 7:29 AM, Jeremy Chone wrote: >> I did not think about the field injection. What are the bad things >> about field injection? > -- You received this message because you are subscribed to the Google Groups "google-guice" 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?hl=en.
