Yes... totally agree. I don't really think that's what I was referring too.
What I was saying was that you should just have all your services ahead of time, that you need. The object that's needed in the hypothetical 'if' block that I was talking about would be created by the injector ahead of time. It's a direct dependency... On Thursday, October 2, 2014 11:35:30 AM UTC-7, Nate Bauernfeind wrote: > > I'm going to point you in the direction of a Guice best-practice guideline > which strongly suggests not doing what you've chosen to do. > > https://github.com/google/guice/wiki/InjectOnlyDirectDependencies > > Specifically, months down the road what if MyObject also needs a > BarService? And then a BazService? Now you're going to have a bunch of > hand-written specific code to do exactly what Guice is supposed to do for > you for free. When does the madness end?! =) > > Good luck, > Nate > > On Thu, Oct 2, 2014 at 12:41 PM, Kevin Burton <[email protected] > <javascript:>> wrote: > >> I think I answered my own question :-P >> >> I think the strategy is to always inject in the constructor. This way >> the entire application won't startup. >> >> Even if it's rarely used, having it from the start of the application >> will fix these problems and your app won't compile without this object in >> the constructor. >> >> >> On Wednesday, October 1, 2014 9:33:42 PM UTC-7, Kevin Burton wrote: >>> >>> I'm curious what the best practice is here. >>> >>> Let's say that deep in your code you wanted to create a new instance of >>> MyObject and pass it a FooService... >>> >>> One could use an injector to do this.. but what if we actually forgot to >>> bind anything to FooService? >>> >>> You would deploy your application, it would be running just fine for >>> months, then all of a sudden you would need FooService and your app would >>> fail. >>> >>> How does one avoid that scenario? >>> >>> If you used explicitly provided dependencies, your app would fail at >>> compilation time. >>> >>> Now we've postponed to fail at run time.. which is not fun. >>> >>> Any solutions here? >>> >> -- >> 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] <javascript:>. >> To post to this group, send email to [email protected] >> <javascript:>. >> Visit this group at http://groups.google.com/group/google-guice. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/google-guice/579a3e9d-c1b6-47f2-b21b-8a7b0f56824b%40googlegroups.com >> >> <https://groups.google.com/d/msgid/google-guice/579a3e9d-c1b6-47f2-b21b-8a7b0f56824b%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> >> For more options, visit https://groups.google.com/d/optout. >> > > -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/google-guice/6d7498ba-348b-436e-b423-e5a609ccf279%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
