Joe Walnes
  Blog



Recent Entries

New blog: http://joewalnes.com

Creative uses of Hamcrest matchers

Hamcrest 1.1 released

Testing on the Toilet

Building testable AJAX apps (Does my button look big in this?)

QDox is back - 1.6 released

Java and .NET RESTful interoperability with XStream

I've joined Google

OSCon: SiteMesh, SiteMesh, SiteMesh, SiteMesh

Flexible JUnit assertions with assertThat()

SiteMesh and Content Management @ O'Reilly OpenSource Conference

XStream 1.1.2 released. Java 5 Enums, JavaBeans, field aliasing, StAX, and more...

VB.Net is the bestest

XStream 1.1.1 released

Accessing generic type information at runtime

XStream 1.1 released

JUnit tip: Setting the default timezone with a TestDecorator

XStream: how to serialize objects to non XML formats

How my backflip went...

Backflippin' in 4 hours.

Is 100% test coverage a BAD thing?

Looking back at the SiteMesh HTML parser

The road ahead for SiteMesh 3

Joe's Backflipping for Autistic Research - time is nearly up...

SiteMesh 2.2 Released

More... [RSS | RDF]

About Joe Walnes

I am a software engineer for Google, based in London.

Open Source

WebStuff (coming soon)

XStream

ActiveMQ

SiteMesh

QDox

nMock

jMock

Pico Container

Nano Container

OpenSymphony

Squiggle

MockDoclet

MockObjects

Jelly

Groovy

PatternStitcher

XJB

Books

Java Open Source Programming, Wiley JSP Site Design, Wrox

Talks

Mock Roles, not Objects
October 26 2004, Vancouver, Canada. OOPSLA'04

Personal Development Practices Map
June 24 2004, Salt Lake City, Utah. Agile Development Conference

SiteMesh.NET and ASP.NET MasterPages
May 20 2004, Bangalore, India. Bangalore .NET User Group

Mock Objects: Driving Top Down Development
March 29 2004, St Neots, UK. OT2004

Mock Objects
December 2 2003, London, UK. XP Day 3


Inversion of Control and Dependency Injector Pattern

Martin Fowler has pubished a new article:

In the Java community there's been a rush of lightweight containers that help to assemble components from different projects into a cohesive application. Underlying these containers is a common pattern to how they perform the wiring, a concept they refer under the very generic name of "Inversion of Control". In this article I dig into how this pattern works, give it the more specific name of "Dependency Injector", and contrast it with the Service Locator alternative. The choice between them is less important than the principle of separating configuration from use.

Read more

Comments

Aslak Hellesoy

The PicoContainer team has decided to embrace this new pattern name: "Constructor based Dependency Injection". This means that we will update the documentation and get rid of the (now obsolete) "IoC type 3" term.

Hani Suleiman

See! I was right all along in my evaluation of thoughtworks employees.

Stephan Schmidt

Hani!

Sam Newman

So IoC was basically a new name for DIP (Dependancy Inversion Principle) now has another new name?
Whatever you call it, the pattern is a good one. Now can we go back to talking about how we use it rather than what its called?

Aslak Hellesoy

Don't underestimate the importance of establishing an unambiguous vocabulary. If the name of the pattern doesn't convey anything meaningful about the principles of the pattern, people are going to have a hard time using it.

DEPENDENCY INJECTOR!! :-)

Now, what did you want to know about the usage of it?

PR

Should the setter injection for the spring framework be called metadata injection then?

Sam Newman

Aslak, you do have a point (actually a point I myself made on my blog a while back but conveniently forgot!). I'm actually a little annoyed because:
a.) We now don't have a nice TLA for it, like we did for DIP or IoC
b.) I just wrote a bloody article on the topic of IoC and now everyones gone and changed their minds about what its called

Anyway, if PicoContainer is now a Constructor based Dependency Injection framework, and Spring a Property/Setter based Dependency Injection framework, is Avalon a Service based Dependency Injection framework? The definitions of the 3 types of IoC frameworks still remain valid if we are talking about Dependency Injection, so we should still be able to talk about Type 1,2 and 3 frameworks I guess.

Kevin Dangoor

Fowler called Avalon's approach "Interface Injection", since it uses interfaces to determine what gets loaded. Personally, I agree with Fowler's point that "Interface", "Setter" and "Constructor" as the three different types of Dependency Injection are easier to remember than Type 1, 2 and 3.

Sam Newman

Kevin, that makes sense to me. Personally the people that talked about Type 1 IoC providing depedencies via services made no sense to me (in so much as EJB is type 1 IoC but doesn't use services in the same way as Avalon)

Pinocio

Dependency Injection is just a way of resolving dependencies in IoC. The are no equality here.

What a confusing term. Dependency information is not injected anywhere, it is pulled out of the objects internals and grouped at the point at which they are constructed (where it should have been all along in a proper OO design).

I don't understand why nobody uses any of the existing names for this architectural style (some which go back oh, 20 years at least).

Kevin

So I have built this plugin engine, similar to Eclipse. It is small, handles plugin lifecycle, dependencies, versioning, load/unload/reload at runtime, embeded jar/zip files within a single archive file (without needing to unzip to dir to use them at runtime), built around extension points and extensions. What is this then? Is it IoC? Or is it something else? It is built on the idea of using small, pluggable modules that can easily be worked into any application, shared across applications, etc. Being only 45K in size with embeded xml pull parser, I like to think of it as yet another container, perhaps a bit more than these IoC containers, but not sure.

Leo Simons

Avalon is not dependency injection, it is service location. It's just that the service locator is then injected. According to the avalon definition of IoC, locating the service locator yourself is not IoC.

Manish Shah

I thought Martin's article gave a clear explanation of the differences between dependency injection and service location. However, for me it missed the key point of constructor dependency injection: Simplicity.

When using Constructor Dependency Injection and TDD, your tests and classes can contain no infrastructure code to do with satisfying dependecies. It is easy to see what you are testing and what you are mocking.

Whilst it is certainly possible to do TDD with the service locator pattern, the set-up and teardown code required makes tests unwieldy.

Chiara

"I don't understand why nobody uses any of the existing names for this architectural style (some which go back oh, 20 years at least)."

Because Fowler likes to blow them off his ass and get credit for them with all the seriousness of a guy who is saving the world. Oh Fowler, shut up already.
I like you Pinocio, because other than all these kiss asses that write here, you stand up and take a stand. My God, it is enough, i am sick of Fowler's patterns, he is gonna call the way i pick my nose a pattern one of these days, and all these idiots are going to start using it.

And it is funny, how now PicoContainer which is the b utt of jokes (sorry, is it needed? what the fuck is it for) are going to gain legality as a pattern itself. Phew, this stinks.

Note: Pinocio didn't write the comment you refer to.

Name:
Email:
URL:

ThoughtBloggers

Martin Fowler

Dan North

Aslak Hellesoy

Darren Hobbs

Geoff Oliphant

Mike Roberts

Chris Stevenson

Jon Tirsen

Loads More...

Agile Bloggers

Ken Arnold

Ward Cunningham

Brian Marick

Robert Martin

Bret Pettichord

Java Bloggers

Ara Abrahamian

Mike Cannon-Brookes

Vincent Massol

Bob McWhirter

Rickard Oberg

Joseph Ottinger

James Strachan

Hani Suleiman

Communities

eXtreme Tuesday Club (XTC)

Thursday GeekSpeek

ThoughtWorks GeekNight

London Java Meetup

The Codehaus

[RSS | RDF]
© 2001-2004, Joe Walnes

Powered by SiteMesh and Moveable Type.