<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ActionScript 3.0 Design Patterns &#187; Quotes</title>
	<atom:link href="http://www.as3dp.com/category/oop-quotes/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.as3dp.com</link>
	<description>OOP Techniques for Flash and Flex Developers</description>
	<lastBuildDate>Sun, 29 Jan 2012 17:00:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Integrating design patterns &quot;just before they become useful&quot;</title>
		<link>http://www.as3dp.com/2009/09/integrating-design-patterns-just-before-they-become-useful/</link>
		<comments>http://www.as3dp.com/2009/09/integrating-design-patterns-just-before-they-become-useful/#comments</comments>
		<pubDate>Thu, 03 Sep 2009 22:53:51 +0000</pubDate>
		<dc:creator>Chandima Cumaranatunge</dc:creator>
				<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[Principles]]></category>
		<category><![CDATA[Quotes]]></category>

		<guid isPermaLink="false">http://www.as3dp.com/?p=1315</guid>
		<description><![CDATA[I recently commented on a provocative post by Jovan Sranojlovic called &#8220;Do Not Use Design Patterns Upfront&#8221; He made some thoughtful observations on why design patterns are important to software engineering and how they can a abused in that context as well. However, I disagreed with his basic thesis that design pattern should only be [...]]]></description>
			<content:encoded><![CDATA[<p>I recently commented on a provocative post by Jovan Sranojlovic called &#8220;<a href="http://blog.jovan-s.com/2009/07/29/do-not-use-design-patterns-upfront/" target="_blank">Do Not Use Design Patterns Upfront</a>&#8221; He made some thoughtful observations on why design patterns are important to software engineering and how they can a abused in that context as well. However, I disagreed with his basic thesis that design pattern should <strong>only</strong> be applied in a <em>code refactoring</em> context and not before. Based on his argument, <em>thinking in design patterns</em> upfront, based on the intent and purpose of code in not good, and even harmful. I tweeted my disagreement with a link to <a href="http://junit.sourceforge.net/doc/cookstour/cookstour.htm" target="_blank">JUnit A Cook&#8217;s Tour</a>, an example of, what I thought was, <em>thinking in design patterns</em> at the application design stage. The resulting tweet stream follows:</p>
<blockquote><p>&#8220;Do Not Use Design Patterns Upfront&#8221; <a href="http://tr.im/uI3a" target="_blank">http://tr.im/uI3a</a> &#8211; I don&#8217;t agree. Beck &amp; Gamma did just that with JUnit <a href="http://tr.im/uI3z" target="_blank">http://tr.im/uI3z</a> #asdp<br />
<em>1:09 AM Jul 30th by </em><a href="http://twitter.com/chandimac" target="_blank">@chandimac</a></p>
<p><a href="http://twitter.com/chandimac" target="_blank">@chandimac</a> no we didn&#8217;t. we explained junit with patterns, but we started with one tiny test and grew the whole thing from there.<br />
<em>6:33 AM Jul 30th by <a href="http://twitter.com/kentbeck" target="_blank">@kentbeck</a> in reply to </em><a href="http://twitter.com/chandimac" target="_blank">@chandimac</a></p>
<p><em><a href="http://twitter.com/kentbeck" target="_blank">@kentbeck</a></em> TX for the clarification. Do you recommend &#8220;thinking in patterns&#8221; early or should they be added at a later refactoring stage?<br />
<em>6:30 AM Jul 31st by </em><a href="http://twitter.com/chandimac" target="_blank">@chandimac</a><em> in reply to </em><em><a href="http://twitter.com/kentbeck" target="_blank">@kentbeck</a></em></p>
<p><a href="http://twitter.com/chandimac" target="_blank">@chandimac</a> i prefer to put patterns in place just before they become useful. if i can&#8217;t see how to do that, then soon after.<br />
<em>6:51 AM Jul 31st by </em><em><a href="http://twitter.com/kentbeck" target="_blank">@kentbeck</a></em><em> in reply to </em><a href="http://twitter.com/chandimac" target="_blank">@chandimac</a></p></blockquote>
<p><a href="http://junit.sourceforge.net/doc/cookstour/cookstour.htm" target="_blank">JUnit A Cook&#8217;s Tour</a> explains the <span>design of a system by starting with nothing and applying patterns, one after another, until you have the architecture of the system. As Kent pointed out, the article was written that way, and </span><span>I had incorrectly assumed that JUnit was developed that way as well.<br />
</span></p>
<h4>Design Pattern wisdom in 140 characters</h4>
<blockquote style="background-color: #99FF33;border: thick double #0066FF;padding: 10px;font-size: 150%;"><p>I put patterns in place just before they become useful. If I can&#8217;t see how to do that, then soon after.</p>
<p>&#8211; Kent Beck</p></blockquote>
<p>I was quite intrigued by Kent&#8217;s reply to my follow up question. It got me thinking about a bunch of issues. What does it mean for a design pattern to be &#8220;useful?&#8221; How much before is &#8220;just before?&#8221; What does it mean to &#8220;put patterns in place?&#8221;</p>
<p>I was so intrigued that I re-read a bunch of stuff on refactoring and design patterns by Beck, Gamma, Kerievsky and Alexander. I try my best to answer some of the questions raised in the remainder of this post &#8211; or more appropriately, reconcile some of my cognitive dissonance.<span id="more-1315"></span></p>
<h4>In which ways are design patterns &#8220;useful?&#8221;</h4>
<p>One of the oft suggested reasons for using design patterns is that they &#8220;make object-oriented design more flexible, elegant, and ultimately reusable.&#8221; That is a direct quote from the GoF Design Patterns book. Although elegance will bring immediate gratification, the fruits of flexibility and re-use are realized in the future, most often during subsequent refactoring. So, in the context of Kent Beck&#8217;s preference to apply patterns just before they become useful; is the only useful reward for thinking in patterns upfront, the personal satisfaction of doing something elegantly?</p>
<p>I think we get a little hung up on the flexibility and re-usability that design patterns bring to software development and forget about another aspect that is equally important.</p>
<p>I  found it helpful to go back to Christopher Alexander&#8217;s  books on architectural patterns and his argument for design patterns in architecture. Good architecture communicates both form and function. Alexander concentrated on deriving the basic functional attributes of different architectural elements. For example, in <a href="http://www.amazon.com/gp/product/0195019199?ie=UTF8&amp;tag=chandimcumara-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0195019199" target="_blank">A Pattern Language</a>, he said the following about the <em>main entrance</em>.</p>
<blockquote><p><span class="h3class">Place the main entrance of the building at a point where it can be seen immediately from the main avenues of approach and give it a bold, visible shape which stands out in front of the building.</span></p></blockquote>
<p>The main entrance can take many forms but its function is common across all main entrances. It has to unambiguously communicate to a person that it is the main entrance. The <em>position</em> of the entrance relative to avenues of approach and its <em>shape</em> compared to other entrances communicates this function. How did Alexander come to this conclusion? By studying main entrances in different buildings designed by different architects and deriving their most salient characteristics.</p>
<p><a href="http://www.flickr.com/photos/deymos/906896797/in/set-72157605867372165/" target="_blank"><img class="alignnone" src="http://farm2.static.flickr.com/1014/906896797_0b6e166549.jpg" alt="" width="200" height="133" /></a> <a href="http://www.flickr.com/photos/25695066@N00/3781968317/" target="_blank"><img class="alignleft" src="http://farm3.static.flickr.com/2650/3781968317_a0b0aefcd2.jpg" alt="" width="200" height="133" /></a></p>
<p>The architectural pattern for the main entrance does not say anything about how the entrance should be built, what materials to use, dimensions and similar minutia. All it does is communicate its functional attributes at a high level.</p>
<p>Software design patterns <em>communicate</em> intent and function at a high level of abstraction as well. This happens at a much higher conceptual level than lines of code, methods, and individual classes. Patterns communicate in the voice of the collective intelligence of thousands of expert developers who tried, tested, modified and otherwise fine-tuned code in response to a common programming problem until a generic pattern could be identified in the solution.</p>
<p>Just like architectural patterns, software design patterns communicate meaning. They not only tell you that there are relationships between classes, but provides reasons for why those relationships exist. Erich Gamma described this very well in <a href="http://www.artima.com/lejava/articles/gammadp.html" target="_blank">How to Use Design Patterns</a> in <em>Leading-Edge Java Magazine</em>. Although JUnit was developed in a test-driven way, Kent and Erich had highly abstract conversations about the design of JUnit using design patterns. Design patterns provided a &#8220;design vocabulary&#8221; to expedite development -  Gamma calls this &#8220;high-velocity design.&#8221;</p>
<p>So, design patterns provide developers with a &#8220;design vocabulary&#8221; to discuss application design. But what about the individual developer? Is the meaning conveyed by a &#8220;design vocabulary&#8221; as useful to an individual developer even if he/she doesn&#8217;t need to communicate it to someone else?</p>
<h4>Is a design vocabulary useful to <em>you</em>?</h4>
<p>Design patterns provide a set of concepts describing how and why a set of classes relate to each other, and the order in which they interact with each other. Forget about flexibility, reusability and elegance for a minute; Is the advantage of being able to visualize code at a higher conceptual level reason enough to think in terms of design patterns upfront? Do a simple test, think of a design pattern that you know and understand well. What comes to mind? Do you see code or something else?</p>
<p>ActionScript 3 developers use design patterns every time we sit down to code. How? because AS3 is rife with native implementations of design patterns. For example, the Flash <em>display list </em>implements a <em>Composite Pattern</em>.  Another example is the AS3 Event model, which follows the <em>Chain of Responsibility</em> <em>Pattern</em> by bubbling events up the display hierarchy.</p>
<p>When I think about nested movie clips, I see hierarchical trees with events shooting up and down the hierarchy like lightning bolts. I find this type of visualization incredibly useful to internalize the relationships between objects. Design patterns provide the scaffolding for me to visualize these relationships.</p>
<p>Jesse Freeman wrote a good article recently called <a href="http://www.insideria.com/2009/08/3-design-patterns-built-into-a.html" target="_blank">3 Design Patterns Built Into AS3</a>. Can you spot others?</p>
<h4>How much before is &#8220;just before?&#8221;</h4>
<p>This is an interesting question as well. If we take the literal meaning of &#8220;just before&#8221; we will miss the point. We must take &#8220;just before&#8221; in the full context of Kent&#8217;s statement. He says &#8220;just before they become useful.&#8221; So, the larger question is when do patterns become useful?</p>
<p>Design patterns allow code to be &#8220;flexible&#8221; allowing  developers to handle change elegantly. Flexible programs are no doubt useful, but are the fruits of flexibility immediately useful? We tend to think  that &#8220;change&#8221; in code as something that happens way down the road, such as the release of a new version of an application. But does &#8220;change&#8221; happen on a day-to-day basis? When you consider that most programming projects are not coded in a day, we realize that programming is a continuous exercise in &#8220;change.&#8221; You may write some code today, but tomorrow you might think that it really &#8220;stinks&#8221; and modify it or scrap it altogether and start afresh.</p>
<p>This is very well described by Kent Beck himself in a callout in the excellent book, <em><a href="https://www.amazon.com/dp/0201485672?tag=chandimcumara-20&amp;camp=213381&amp;creative=390973&amp;linkCode=as4&amp;creativeASIN=0201485672&amp;adid=0MPG8DN0YMP72QCGPE46&amp;" target="_blank">Refactoring: Improving the Design of Existing Code</a></em>.</p>
<blockquote><p>Programs have two kinds of value: what they can do for you today and what they can do for you tomorrow&#8230;.If you can get today&#8217;s work done today, but you do it in such a way that you can&#8217;t possibly get tomorrow&#8217;s work done tomorrow, then you lose.</p></blockquote>
<p>For example, you may have an inkling that the algorithm you are using today may not be optimal, and decide to integrate a strategy pattern so that it gives you the flexibility to integrate a different algorithm tomorrow without disrupting existing code.</p>
<p>I do realize that Kent&#8217;s quote was made in the context of refactoring code. Refactoring to design patterns is also refactoring. So, is putting a pattern in place today to  ease tomorrows work considered &#8220;just before it becomes useful?&#8221; What do you think?</p>
<h4>What does it mean to &#8220;put patterns in place?&#8221;</h4>
<p>The original question that prompted me to write this article was whether design patterns should be put in place only in a refactoring context or whether it is useful to think in terms of design patterns upfront as well. One argument can be that it depends on the development methodology.</p>
<p>For example, if you follow an <em>agile</em> development approach, design emerges from iterative refactoring. In most cases, development relies on <em>feedback</em> provided by tests to drive the design. In this scenario there is not much option but to put design patterns in place during refactoring.</p>
<p>On the other hand, if you follow a more <em>prescriptive</em> approach ( for want of a better term ), there is an emphasis on <em>planning</em> and <em>modeling </em>before coding. In this scenario, there is an opportunity to put patterns in place up front.</p>
<p>One could also argue that it really doesn&#8217;t matter because in most projects we use a combination of both development methods.</p>
<p>Ultimately my driving question will probably transform into an argument between the merits of different development methodologies. There is no doubt as to the &#8220;usefulness&#8221; of design patterns and it may not matter whether you put them into place up front or during refactoring &#8211; either way, you will get the benefits.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.as3dp.com%2F2009%2F09%2Fintegrating-design-patterns-just-before-they-become-useful%2F&amp;title=Integrating%20design%20patterns%20%26quot%3Bjust%20before%20they%20become%20useful%26quot%3B" id="wpa2a_2"><img src="http://www.as3dp.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.as3dp.com/2009/09/integrating-design-patterns-just-before-they-become-useful/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>OOP Quote #1</title>
		<link>http://www.as3dp.com/2009/06/oop-quote-1/</link>
		<comments>http://www.as3dp.com/2009/06/oop-quote-1/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 09:19:55 +0000</pubDate>
		<dc:creator>William B. Sanders</dc:creator>
				<category><![CDATA[Quotes]]></category>

		<guid isPermaLink="false">http://www.as3dp.com/?p=1120</guid>
		<description><![CDATA[Every now and then I find a quote about OOP or Design Patterns that I constantly reference. Instead of popping them into a text file (as I now do) I decided to put them in AIR apps. Then I could make them look like those goofy employee inspiration quotes some companies plaster around the cubicles [...]]]></description>
			<content:encoded><![CDATA[<p>Every now and then I find a quote about OOP or Design Patterns that I constantly reference. Instead of popping them into a text file (as I now do) I decided to put them in AIR apps. Then I could make them look like those goofy employee inspiration quotes some companies plaster around the cubicles (e.g., &#8220;Soar like an eagle!&#8221;). However, instead of inspiration, I chose reminders of what it means to write good OOP or DP. They&#8217;re not exactly the same as principles (which are in another AIR app) but just good guides. <a href="http://www.sandlight.net/dpBlog/oopquotes/">You can download them here in AIR files.</a></p>
<p>Here&#8217;s the first one, which you may recognize from previous posts:</p>
<p><img src="http://www.as3dp.com/wp-content/uploads/2009/06/oopquote1.png" alt="oopquote1" title="oopquote1" width="500" height="384" class="alignnone size-full wp-image-1123" /></p>
<p>If you have any similar quotes that you find instructive, send them along with their source, and we&#8217;ll put them up.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.as3dp.com%2F2009%2F06%2Foop-quote-1%2F&amp;title=OOP%20Quote%20%231" id="wpa2a_4"><img src="http://www.as3dp.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.as3dp.com/2009/06/oop-quote-1/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

