O'Reilly logo

Learning Google Guice by Hussain Pithawala

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Comparing two approaches

We will now have a look at two applications with the same application logic. One is developed using direct dependency initialization and other using dependency injection with Guice. Though trivial, these applications help us better understand what we have theoretically discussed so far.

Initializing dependencies directly

We will first try to develop the application wherein we try to initialize dependencies and assign them manually. Let's consider a fictitious application for searching flights, where we try to prepare and inject dependencies manually via a constructor. A FlightEngine is a class, which processes the request via a value object SearchRequest and returns the response via a value object SearchResponse. FlightEngine ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required