------ art_40050_32918619.1181825572400 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 6/14/07, Robert Klemme <shortcutter / googlemail.com> wrote: > > On 14.06.2007 12:04, Trans wrote: > > On Jun 8, 10:47 pm, Daniel DeLorme <dan... / dan42.com> wrote: > >> I think the best article on the topic is this by Martin Fowler: > http://www.martinfowler.com/articles/injection.html > >> He does a good job of analyzing the pros and cons. And basically I > agree > >> with him; DI is useless unless you write 3rd party packages. > > > > For a long time I felt DI was very interesting and potentially very > > useful, but I never could quite get mileage out of it. I think I > > finally figured out why: DI is just a contrived codification of an > > essentially simple top-level construction layer. Here's what I mean. > > Reading Jim's http://onestepback.org/articles/depinj/, he gives this > > basic example: > > Isn't DI just about callbacks? If that was the case DI is all over Ruby > code - every block is an anonymous callback function. > > Kind regards > > robert DI just about callbacks? You need to go read up on DI. Dependency Injection is all about keeping components as uncoupled as possible. This usually means that each object takes in it's constructor, or has setter methods for, the objects it needs to function. E.g.: class MyClass < ... def initialize(logger, my_worker, ...) @logger ogger @my_worker orker end end This makes testing MyClass extremely easy (on top of this being Ruby anyway) and very extensible. So yeah, Dependency Injection itself has *nothing* to do with callbacks. Jason ------ art_40050_32918619.1181825572400--