From: Christian Neukirchen Date: 2005-09-26T22:22:52+09:00 Subject: Re: [ANN] My dependency-injection library Nikolai Weibull writes: > OK. So Ruby has enough dependency-injection/inversion-of-control > libraries as it is, but mine is quite different so I figured I’d post > it. It’s about as simple as dependency-injection can possibly become > and there’s no support for lifecycles, interception, or other framework > stuff. Nor is there any support for parents, children, or other > relatives, so keep it to yourself. Interesting idea, but you are only pushing constants around? Can't we do that easier? > class Scanner > def initialize(io) > raise Error, "can only work with open io-ports" if io.closed? > @io = io > end > end > class Error < ScriptError; end # Or something more creative, perhaps? Scanner::Error = Error > class TC_Driver < Test::Unit::TestCase > ⋮ > end > So the idea is that under normal circumstances, ‘needs’ is just a > circumvention for not using ‘require’ directly, but for trying times the > dependency can be changed to something more suitable. I really fail to see the advantage of using this over manual require and dependency setting. :-) I personally would expect a DI framework to at least provide a singleton instantiation scheme, else it wouldn't make any sense to me at all. Einstein once said "Everything should be made as simple as possible, but not simpler". I think anything more simple than Matz-DI is too simple. > http://onestepback.org/articles/depinj/matz/index.html > nikolai -- Christian Neukirchen http://chneukirchen.org