Search code examples
gwtdependency-injectiongwt-gin

GWT : DI via Gin vs GWT Deferred Binding


I'm new to GWT, but I'm not new to Dependency Injection.

I'm looking for some concrete differences between DI via Gin and GWT Deferred Binding. I've used DI in the past to de-couple my app by injecting dependencies, and it seems that Deferred Binding does that also, just in a more explicit way, and geared more toward browser compatibility.

What are the key differences, and do I need to choose one over the other, or are they complimentary.

We're building a new app and we want this foundation to be solid.


Solution

  • Gin uses Deferred Binding to create all instances in that way the app is configured. So you can use Deferred Binding to do the job.

    But: With Gin you can configure if an instance should be a singleton or a prototyp. If you want to do this with Deferred Binding you have to write more code.

    The DI Annotation are better known and every one knowing DI knows about @Inject. This makes the code better readable.

    Deferred Binding does only work in GWT and if you use Deferred Binding to wire you objectes you have problems to run unit tests directly and fast in the jvm. If you use Gin you can use Guice or wire you objects by hand in order to test your code in the jvm.

    I think, these are the main advantages of Gin.