Questions tagged [google-guice]

Google Guice is an open source dependency injection framework for Java, developed by Google. _Description courtesy of [Wikipedia](http://en.wikipedia.org/wiki/Google_Guice)_

Google Guice (pronounced "juice") is an open source software framework for the Java platform released by Google under the Apache License. It provides support for dependency injection using annotations to configure Java objects. Dependency injection is a design pattern whose core principle is to separate behavior from dependency resolution.

Guice allows implementation classes to be bound programmatically to an interface, then injected into constructors, methods or fields using an @Inject annotation. When more than one implementation of the same interface is needed, the user can create custom annotations that identify an implementation, then use that annotation when injecting it.

Being the first generic framework for dependency injection using Java annotations in 2008, Guice won the 18th Jolt Award for best Library, Framework, or Component.

Description courtesy of Wikipedia

9 questions
55
votes
4 answers

Why do we need frameworks for dependency injection?

I've been reading up more on the Inversion of Control principle and Dependency Injection as an implementation of it and am pretty sure I understand it. It seems to be basically saying 'don't declare your class members' instantiations within the…
9
votes
2 answers

Gradually move codebase to dependency injection container

I have a large codebase with a lot of "anti-pattern" singletons, utility classes with static methods and classes creating their own dependencies using new keyword. It makes a code very difficult to test. I want to gradually migrate code to…
damluar
  • 217
  • 2
  • 6
8
votes
4 answers

What complexity do DI frameworks add?

The currently most upvoted answer to a very recent question states that DI containers are an "enterprise software" pattern, used when the object graph is very large and complex. I suspect that 95% of applications do not require it. which is…
maaartinus
  • 2,633
  • 1
  • 21
  • 29
6
votes
1 answer

Passing a Context around with dependency injection

In the project I'm working on, I'm using Guice and trying to do as much as possible with Dependency Injection. However, there's one little snag; many of my objects rely on an object Context. This is an immutable object but has some information which…
durron597
  • 7,590
  • 9
  • 37
  • 67
3
votes
3 answers

Where should I put bindings for dependency injection?

I'm new to dependency injection and though I've really liked it so far, I'm not sure where bindings should go. I'm using Guice in Java, so some of what I say might be specific to just Guice. As I see it, there's two options: Accompanying the…
sinθ
  • 1,311
  • 15
  • 25
1
vote
2 answers

Can I use a library that uses guice to bind contact and implementations in applications without issues?

I have a play application and want to take a common operation out from the application and make it as a library in order to use in other play applications. This proposing library has a contract(interface) and several implementations of top of…
1
vote
2 answers

Opportunity cost of DIY DI?

Java here. I have always used Spring DI (for Spring projects) or Guice (for non-Spring projects) for dependency injection, and have always loved them. I recently took a job where they do 100% "DIY DI". That is, every project's main/driver class has…
smeeb
  • 4,820
  • 10
  • 30
  • 49
1
vote
3 answers

How to use Guice for an effective API Design?

I am creating a base API in JavaSE, which includes modules like MVP architecture, Service & Repository Layer, Event Model to fire events between presenter etc. I am trying to implement all best practices of Software Design. Recently, I read about…
Akshat
  • 119
  • 1
  • 5
1
vote
1 answer

Do my "dal" and "fileHandler" interfaces overlap?

I want my program to: read some input lines from CSV file write the output lines to plain string file read some input from the same file in (2) and compare it to some calculated data I want to consider these abstraction levels: create Dal…
user23621
  • 181
  • 1
  • 7