<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>tag:blogger.com,1999:blog-3466723300364899720.post8333433746237112397..comments</id><updated>2011-09-19T14:21:52.074-04:00</updated><category term='ruby'/><category term='gender'/><category term='ood'/><title type='text'>Comments on Sandi Metz: SOLID Design Principles - Dependency Injection</title><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://sandimetz.com/feeds/8333433746237112397/comments/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3466723300364899720/8333433746237112397/comments/default'/><link rel='alternate' type='text/html' href='http://sandimetz.com/2009/03/solid-design-principles-dependency.html'/><author><name>Sandi Metz</name><uri>http://www.blogger.com/profile/13364323780338797977</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://3.bp.blogspot.com/-DpVpPSW2Guw/TzEhPNc7skI/AAAAAAAAAYI/ABtohVAnlNg/s220/me_twitter_broader.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>7</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3466723300364899720.post-2745370340627524448</id><published>2011-09-19T14:21:52.074-04:00</published><updated>2011-09-19T14:21:52.074-04:00</updated><title type='text'>what do rubyists think of DIP (depending on abstra...</title><content type='html'>what do rubyists think of DIP (depending on abstractions, not concretions?). Does this apply to Ruby at all?</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3466723300364899720/8333433746237112397/comments/default/2745370340627524448'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3466723300364899720/8333433746237112397/comments/default/2745370340627524448'/><link rel='alternate' type='text/html' href='http://sandimetz.com/2009/03/solid-design-principles-dependency.html?showComment=1316456512074#c2745370340627524448' title=''/><author><name>Steve-o</name><uri>http://www.blogger.com/profile/15648501950093965704</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://sandimetz.com/2009/03/solid-design-principles-dependency.html' ref='tag:blogger.com,1999:blog-3466723300364899720.post-8333433746237112397' source='http://www.blogger.com/feeds/3466723300364899720/posts/default/8333433746237112397' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1333755544'/></entry><entry><id>tag:blogger.com,1999:blog-3466723300364899720.post-2579597569791980469</id><published>2009-06-04T07:03:43.803-04:00</published><updated>2009-06-04T07:03:43.803-04:00</updated><title type='text'>@Michael  The code is formatted with CodeRay, whic...</title><content type='html'>@Michael  The code is formatted with CodeRay, which rocks. It requires the CodeRay gem and something like this &lt;a href="http://gist.github.com/123567" rel="nofollow"&gt;gist&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;@Erich  I totally agree.  Isolating the creation of a new object into a method of its own is a good compromise between injecting the class (complete separation) and creating it in the middle of a bunch of other code (complete entanglement).  This is all about preserving the most future &lt;i&gt;options&lt;/i&gt; at the lowest present &lt;i&gt;cost&lt;/i&gt;.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3466723300364899720/8333433746237112397/comments/default/2579597569791980469'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3466723300364899720/8333433746237112397/comments/default/2579597569791980469'/><link rel='alternate' type='text/html' href='http://sandimetz.com/2009/03/solid-design-principles-dependency.html?showComment=1244113423803#c2579597569791980469' title=''/><author><name>Sandi Metz</name><uri>http://www.blogger.com/profile/13364323780338797977</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://sandimetz.com/2009/03/solid-design-principles-dependency.html' ref='tag:blogger.com,1999:blog-3466723300364899720.post-8333433746237112397' source='http://www.blogger.com/feeds/3466723300364899720/posts/default/8333433746237112397' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1574250197'/></entry><entry><id>tag:blogger.com,1999:blog-3466723300364899720.post-3389096497089944181</id><published>2009-06-02T19:21:25.790-04:00</published><updated>2009-06-02T19:21:25.790-04:00</updated><title type='text'>@Sandi:
&amp;gt; For non-framework code, I often still...</title><content type='html'>@Sandi:&lt;br /&gt;&amp;gt; For non-framework code, I often still explicitly create the objects that I depend on.&lt;br /&gt;&lt;br /&gt;This is ok. NTL I learned that you should at least refactor the creation of an object into an overridable factory method. This makes it easy to intercept or replace the creation if necessary. I seldom write &amp;#39;new&amp;#39; in the middle of a statement block anymore.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3466723300364899720/8333433746237112397/comments/default/3389096497089944181'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3466723300364899720/8333433746237112397/comments/default/3389096497089944181'/><link rel='alternate' type='text/html' href='http://sandimetz.com/2009/03/solid-design-principles-dependency.html?showComment=1243984885790#c3389096497089944181' title=''/><author><name>Erich Eichinger</name><uri>http://www.blogger.com/profile/01777569034256321263</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://sandimetz.com/2009/03/solid-design-principles-dependency.html' ref='tag:blogger.com,1999:blog-3466723300364899720.post-8333433746237112397' source='http://www.blogger.com/feeds/3466723300364899720/posts/default/8333433746237112397' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1927532409'/></entry><entry><id>tag:blogger.com,1999:blog-3466723300364899720.post-2311759788594088205</id><published>2009-06-01T16:00:22.980-04:00</published><updated>2009-06-01T16:00:22.980-04:00</updated><title type='text'>Glad to see the D of SOLID in Ruby is getting atte...</title><content type='html'>Glad to see the D of SOLID in Ruby is getting attention.  What plugin do you use for your code snippets?  They look nice :)</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3466723300364899720/8333433746237112397/comments/default/2311759788594088205'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3466723300364899720/8333433746237112397/comments/default/2311759788594088205'/><link rel='alternate' type='text/html' href='http://sandimetz.com/2009/03/solid-design-principles-dependency.html?showComment=1243886422980#c2311759788594088205' title=''/><author><name>Michael Brennan</name><uri>http://www.blogger.com/profile/09351708784127332440</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://4.bp.blogspot.com/_JW7gLMzR6nE/ShwRfYhkB7I/AAAAAAAAAbw/9zFSNMKePsg/S220/me2.png'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://sandimetz.com/2009/03/solid-design-principles-dependency.html' ref='tag:blogger.com,1999:blog-3466723300364899720.post-8333433746237112397' source='http://www.blogger.com/feeds/3466723300364899720/posts/default/8333433746237112397' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-609102462'/></entry><entry><id>tag:blogger.com,1999:blog-3466723300364899720.post-5241804962428620031</id><published>2009-04-15T07:31:00.000-04:00</published><updated>2009-04-15T07:31:00.000-04:00</updated><title type='text'>Ah, Pat, the to_xml example is definitely the rub....</title><content type='html'>Ah, Pat, the to_xml example is definitely the rub.  It goes right to the heart of the issue: Is it good style to inject dependencies even when your current use case does not anticipate changes? &lt;br /&gt;&lt;br /&gt;When I write code I've historically done just what they did, i.e., in the initialize methods of *my* objects I get new instances of the *other* objects I depend on.   However, I keep getting burned, either because my code is hard to test or because I have an unexpected need to reuse the code with a different dependency.&lt;br /&gt;&lt;br /&gt;I'm holding myself to two different standards.  When I write framework code that I expect others to heavily reuse, I inject like mad even if I don't have a current need. In this case it feels like my obligation is to support unexpected collaborations among objects which have well defined APIs.  This ability to easily make new collaborations is a design goal of the framework.&lt;br /&gt;&lt;br /&gt;For non-framework code, I often still explicitly create the objects that I depend on.  Mostly.  Except when it's easier to write tests if I don't.  And these dependencies lasts until I find a need for reuse and refactor the code..&lt;br /&gt;&lt;br /&gt;As you can see, this is still of an experiment about dependency management.  We'll see how it goes. &lt;br /&gt;&lt;br /&gt;Excellent that you'll be at GoRuCo.  I'm up for a face-to-face chat!</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3466723300364899720/8333433746237112397/comments/default/5241804962428620031'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3466723300364899720/8333433746237112397/comments/default/5241804962428620031'/><link rel='alternate' type='text/html' href='http://sandimetz.com/2009/03/solid-design-principles-dependency.html?showComment=1239795060000#c5241804962428620031' title=''/><author><name>Sandi Metz</name><uri>http://www.blogger.com/profile/13364323780338797977</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://sandimetz.com/2009/03/solid-design-principles-dependency.html' ref='tag:blogger.com,1999:blog-3466723300364899720.post-8333433746237112397' source='http://www.blogger.com/feeds/3466723300364899720/posts/default/8333433746237112397' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1574250197'/></entry><entry><id>tag:blogger.com,1999:blog-3466723300364899720.post-7079967908455097515</id><published>2009-04-12T13:10:00.000-04:00</published><updated>2009-04-12T13:10:00.000-04:00</updated><title type='text'>I love "free" dependency injection.  When you're d...</title><content type='html'>I love "free" dependency injection.  When you're dealing with old crap&lt;BR/&gt;code, you can break dependencies to make it more testable, but&lt;BR/&gt;maintain the same API by using default args as you've shown.  This&lt;BR/&gt;makes your code more testable without breaking existing clients.  Huge&lt;BR/&gt;win.&lt;BR/&gt;&lt;BR/&gt;As for your to_xml example, I can go both ways on that.  First there's&lt;BR/&gt;the idea that you shouldn't build flexibility in that you don't&lt;BR/&gt;need...the lack of a configurable serializer is not necessarily an&lt;BR/&gt;oversight on their part.  You should refactor that flexibility in when&lt;BR/&gt;you need it.  If you did that though, then wouldn't the first&lt;BR/&gt;iteration of every project be one big ol imperative script, with no&lt;BR/&gt;organization whatsoever, right?&lt;BR/&gt;&lt;BR/&gt;There's a common theme running through the Rails code base, and that&lt;BR/&gt;theme is that it's not extensible using standard OOP techniques.  They&lt;BR/&gt;have hook points for high-level behavior, but if you want to change&lt;BR/&gt;stuff under the hood then you're in for a lot of alias_method_pain.&lt;BR/&gt;&lt;BR/&gt;I was about to say that the D in SOLID seems to be neglected in our&lt;BR/&gt;world...but I'd say that it's SOLID in general that is.  Nice to see&lt;BR/&gt;you getting the word out!  Also I'm attending GoRuCo, can't wait to&lt;BR/&gt;hang out again!!</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3466723300364899720/8333433746237112397/comments/default/7079967908455097515'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3466723300364899720/8333433746237112397/comments/default/7079967908455097515'/><link rel='alternate' type='text/html' href='http://sandimetz.com/2009/03/solid-design-principles-dependency.html?showComment=1239556200000#c7079967908455097515' title=''/><author><name>Pat Maddox</name><uri>http://www.blogger.com/profile/08736213150610301698</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://sandimetz.com/2009/03/solid-design-principles-dependency.html' ref='tag:blogger.com,1999:blog-3466723300364899720.post-8333433746237112397' source='http://www.blogger.com/feeds/3466723300364899720/posts/default/8333433746237112397' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-324953442'/></entry><entry><id>tag:blogger.com,1999:blog-3466723300364899720.post-8417018544122397448</id><published>2009-03-28T12:51:00.000-04:00</published><updated>2009-03-28T12:51:00.000-04:00</updated><title type='text'>Hi Sandi,&lt;br&gt;&lt;br&gt;Great writeup! Nice simplificatio...</title><content type='html'>Hi Sandi,&lt;BR/&gt;&lt;BR/&gt;Great writeup! Nice simplification of dependency injection. So many people think of frameworks like Spring and others from the Java world every time someone talks about dependency injection.&lt;BR/&gt;&lt;BR/&gt;Mark Menard&lt;BR/&gt;&lt;BR/&gt;PS: We met at Obie Con in Boston in November.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3466723300364899720/8333433746237112397/comments/default/8417018544122397448'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3466723300364899720/8333433746237112397/comments/default/8417018544122397448'/><link rel='alternate' type='text/html' href='http://sandimetz.com/2009/03/solid-design-principles-dependency.html?showComment=1238259060000#c8417018544122397448' title=''/><author><name>Vita Rara</name><uri>http://www.blogger.com/profile/14237598315022861781</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://sandimetz.com/2009/03/solid-design-principles-dependency.html' ref='tag:blogger.com,1999:blog-3466723300364899720.post-8333433746237112397' source='http://www.blogger.com/feeds/3466723300364899720/posts/default/8333433746237112397' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-55217981'/></entry></feed>
