Just A Summary : Tag thequalitywithoutaname, everything about thequalitywithoutaname http://www.bofh.org.uk/articles/tag/thequalitywithoutaname.rss en-us 40 Piers Cawley Practices Punditry Applying design patterns unconsciously <p>I just realised something about the workings of new style Typo Sidebars: it&#8217;s just an application of the <a href="http://www.c2.com/cgi/wiki?ParameterObject">Parameter Object</a> design pattern; the <code>render_sidebar</code> helper method takes a <code>Sidebar</code> parameter object and produces a chunk of <span class="caps">HTML</span>. The fact that we persist the parameter object using ActiveRecord is almost beside the point &#8211; the persistence is more important to the  <code>render_sidebars</code> method than anything else.</p> <p>Old style sidebars couldn&#8217;t really be called an application of any design pattern. Maybe that&#8217;s what bugged me about them, they lacked the <a href="/articles/2003/07/29/the-quality-without-a-name">Quality Without a Name</a>. I&#8217;m not sure that the new sidebar architecture has the Quality either, but it&#8217;s much nearer to having it.</p> <p>When I was learning to play <a href="http://en.wikipedia.org/wiki/Go">Go</a> someone told me that it&#8217;s easier to remember professional games than those of amateurs because the moves in a professional game are generally more &#8216;right&#8217; than those of weaker players. To a good go player, the &#8216;right&#8217; move has an obvious purpose (or, more likely, purposes). Bad moves don&#8217;t.</p> <p>Maybe something similar applies to code. In good code it&#8217;s clear what each piece does &#8211; maybe it can be seen as an example of a design pattern, maybe not &#8211; and the pieces relate well to each other. In bad code, the intent and relationships are muddied. </p> <h3>Do Design Patterns Help?</h3> <p>Continuing the Go analogy, Design patterns can be likened to <a href="http://senseis.xmp.net/?Joseki"><em>joseki</em></a> &#8211; &#8216;standard&#8217; patterns of good play in the opening of the game. It&#8217;s useful to know them, but what&#8217;s <em>really</em> important, and what takes time, practice and deep study to get good at, is using and adapting them well in the <a href="http://senseis.xml.net/?Fuseki"><em>fuseki</em></a> &#8211; the opening and its wider context. You can play a &#8216;perfect&#8217; joseki in one little corner, but its influence radiates across the board and if you don&#8217;t pay attention to what that influence is and use or adapt it well, you&#8217;re screwed.</p> <p>I think the analogy to the use of design patterns in programming is fairly obvious. Don&#8217;t you?</p> Mon, 21 Aug 2006 07:33:00 -0500 urn:uuid:d7dce296-7007-4841-9611-a749c48eb89a pdcawley@bofh.org.uk (Piers Cawley) http://www.bofh.org.uk/articles/2006/08/21/applying-design-patterns-unconsciously#comments The Practice of Programming Typo designpatterns thequalitywithoutaname http://www.bofh.org.uk/trackbacks?article_id=applying-design-patterns-unconsciously&day=21&month=08&year=2006 http://www.bofh.org.uk/articles/2006/08/21/applying-design-patterns-unconsciously