Memoization as Dependency Injection

J

James Bowery

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?
 
J

Jamis Buck

James said:
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/DependencyInjectionInRuby.rdoc

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,525
Members
44,997
Latest member
mileyka

Latest Threads

Top