I somehow mangled the message while editing.  I meant to say:

"... an artifact of wiring up one ..."

"A class should not care if there is one instance of it or more than one instance of it around..."

----- Original Message ----- From: "Anil Gangolli" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, May 20, 2007 9:16 AM
Subject: DI and singletons



I notice that I had missed the entire thread about Guice on this list before seeing the commit go by and commenting on that.

I also noticed a discussion of singletons. One of the lessons I've learned from using DI is that the notion of singleton is best not inherently represented in the code, but rather just as an artifact wiring up one instance of a dependency to be used by a set of other objects. A class should not care if there is one instance of it or than one instance of it around; it can just deal with its members. This also tends to clarify the abstraction of what the singleton is doing and open things up; sometimes you find that you want to allow for different implementations.

--a.


Reply via email to