[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Memoization as Dependency Injection

jim_bowery

11/19/2004 2:49:00 AM

I'm probably missing something about the concept of dependency
injection (I'm sure I'm not the first) but what is it about DI that
isn't this reducible to memoization of getters?
1 Answer

Jamis Buck

11/19/2004 3:12:00 AM

0

James Bowery wrote:
> I'm probably missing something about the concept of dependency
> injection (I'm sure I'm not the first) but what is it about DI that
> isn't this reducible to memoization of getters?
>
> .
>

Well, DI is a lot more than caching the services that get created. For
example, in Needle, you can have prototype services, which are created
on every request instead of being cached.

In fact, memoization of services is not even directly related to DI.

That said, DI is all about some third party hooking up dependencies for
an application. Think of it as an online dating system for your
application components. _The container_ knows all the pieces, and it
knows how to couple them all together as needed.

Have you read Jim Weirich's article on dependency injection in Ruby?
http://onestepback.org/index.cgi/Tech/Ruby/DependencyInjectionI...

If you haven't, you really ought to. If you have, I'd be happy to put in
a few more words of clarification on the subject.

- Jamis

--
Jamis Buck
jgb3@email.byu.edu
http://www.jamisbuck...