This post originated from an RSS feed registered with Java Buzz
by dion.
Original Post: Explaining why Dependency Injection is good
Feed Title: techno.blog(Dion)
Feed URL: http://feeds.feedburner.com/dion
Feed Description: blogging about life the universe and everything tech
Rickard has done a really good job and explaining why DI is good.
In a very simple, scientific way, he details the simpliest of examples (Foo depending on Bar), and shows how the properties of different designs affect your agility.
I really like how he explains these properties:
This code has the following properties:
Bar can be a class, an abstract class, or an interface
Foo does not need to know how Bar is instantiated
The Bar instance can be used by other components
Bar can have any configuration needs
The user of Foo needs to know how to provide a Bar
Many people know that they enjoy moving to this model when designing their code, but don't know how to explain why they like it so much. On one hand people say "it is just a constructor / setter / ...".