Is that going to play nice with inheritance? Let's say you have a inheritance chain of three levels, and next to a public constructor (with args) in the parent type you add a new constructor. Now the two types below have an extra constructor, and Guice will blow up if you use one of them. So now you have to know that it's actually the parent type that causes the other two types to fail (obviously you could also annotate the parent's constructor, but you don't always use the parent type with Guice).
Robbie On Mon, Oct 6, 2008 at 4:27 PM, James Strachan <[EMAIL PROTECTED]>wrote: > > It seems if you have an object with a single public constructor - you > still must add the @Inject annotation. I just wondered what the > rational was for this - it kinda feels a tad overzealous? I kinda like > the idea of encouraging folks to write classes with a single > constructor (similar to the google collections folks found when > writing collections) and as a small side benefit it would be kinda > nice that they can omit the @Inject. > > I guess the worry is, if you refactor the code and add a new > constructor, code might break. But it'd be pretty obvious what broke > as you make the refactoring, so it'd be easy to add the @Inject when > you do want to add another constructor. Any other reasons for this > strict rule? > > -- > James > ------- > http://macstrac.blogspot.com/ > > Open Source Integration > http://open.iona.com > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
