Home » Tag Archives: Dependency Injection (page 2)

Tag Archives: Dependency Injection

Spring 3: Type safe dependency injection

spring-interview-questions-answers

Before jumping to Type Safe Dependency Injection from Spring, I would like to to discuss the way we have been doing it earlier. We have been using dependency injection by type with the help of Autowired annotation from Spring. Something like this would inject the spring bean. @Autowired private StudentDao studentDao; // Autowires by type. Injects the instance whose type ...

Read More »

DI in Scala: Cake Pattern pros & cons

scala-logo

I’ve been looking at alternatives for java-style DI and DI containers which would use pure Scala; a promising candidate is the Cake Pattern (see my earlier blog post for information on how the Cake Pattern works). FP enthusiast also claim that they don’t need any DI frameworks, as higher-order functions are enough. Recently Debasish Ghosh also blogged on a similar ...

Read More »

Rich Domain Model with Guice

google-logo

The anaemic domain model is a really common anti-pattern. In the world of ORM & DI frameworks we naturally seem to find ourselves with an ORM-managed “domain” that is all data and no behaviour; coupled with helper classes that are all behaviour and no data, helpfully injected in by our DI framework. In this article I’ll look at one possible ...

Read More »

On DTOs

java-interview-questions-answers

DTOs, or data-transfer objects, are commonly used. What is not s? commonly-known is that they originate from DDD (Domain-driven design). There it makes a lot of sense – domain objects have state, identity and business logic while DTOs have only state. But many projects today are using the anemic data model approach (my opinion) and still use DTOs. They are ...

Read More »

On domain-driven design, anemic domain models, code generation, dependency injection and more…

java-interview-questions-answers

Eric Evans has formulated what domain-driven design (DDD) is. Martin Fowler is a great supporter and advocate of DDD. These are remarkable names and it is almost certain they are supporting something worth. And I’m not here to argue with that. Maybe I’m trying to justify the way I’ve been writing software, or maybe I’m trying just to clear things ...

Read More »

The evolution of Spring dependency injection techniques

spring-interview-questions-answers

Looking back at the history of Spring framework you will find out that the number of ways you can implement dependency injection is growing in every release. If you’ve been working with this framework for more than a month you’ll probably find nothing interesting in this retrospective article. Nothing hopefully except the last example in Scala, language that accidentally works ...

Read More »

Android Dependency Injection and Testing Libraries

android-logo

Anything and everything that makes life easier to develop for Android should be looked into. There are a couple of libraries that make testing easier, increase the modularity of your code, and provide already created mock objects: RoboGuice – This is an adaption of Google’s dependency injection library but for Android Robolectric -This is a testing framework/platform which works to remove the ...

Read More »

Dependency Injection – The manual way

spring-interview-questions-answers

Dependency injection is a technique that separates behavior from dependency resolution. In simpler words, it allows the developer to define classes with specific functionality that depends on various collaborators, without having to define how reference to these collaborator will be obtained. In that way, decoupling among the various components is achieved and cleaner code is introduced in general. More specifically, ...

Read More »
Want to take your Java Skills to the next level?
Grab our programming books for FREE!
  • Save time by leveraging our field-tested solutions to common problems.
  • The books cover a wide range of topics, from JPA and JUnit, to JMeter and Android.
  • Each book comes as a standalone guide (with source code provided), so that you use it as reference.
Last Step ...

Where should we send the free eBooks?

Good Work!
To download the books, please verify your email address by following the instructions found on the email we just sent you.