<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Burcu Dogan&#039;s Blog &#187; software design</title>
	<atom:link href="http://burcudogan.com/tag/software-design/feed/" rel="self" type="application/rss+xml" />
	<link>http://burcudogan.com</link>
	<description>Burcu Dogan is a software engineer, a technologist and an open source enthusiastic.</description>
	<lastBuildDate>Thu, 05 Jan 2012 08:01:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='burcudogan.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Burcu Dogan&#039;s Blog &#187; software design</title>
		<link>http://burcudogan.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://burcudogan.com/osd.xml" title="Burcu Dogan&#039;s Blog" />
	<atom:link rel='hub' href='http://burcudogan.com/?pushpress=hub'/>
		<item>
		<title>Using Paper and Pencil Before Coding</title>
		<link>http://burcudogan.com/2009/04/18/using-paper-and-pencil-before-coding/</link>
		<comments>http://burcudogan.com/2009/04/18/using-paper-and-pencil-before-coding/#comments</comments>
		<pubDate>Sat, 18 Apr 2009 18:02:40 +0000</pubDate>
		<dc:creator>Burcu Dogan</dc:creator>
				<category><![CDATA[Regular]]></category>
		<category><![CDATA[deep thinking]]></category>
		<category><![CDATA[software design]]></category>

		<guid isPermaLink="false">http://blog.burcudogan.com/?p=210</guid>
		<description><![CDATA[I don&#8217;t remind myself starting to code, even a single tiny function, without illustrating it on paper. Do I write code on paper? Yes, I also do that. I adore coding on whiteboards where many people can come together on a coffee break and discuss. Most of the young developers ignore that single rule in [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=burcudogan.com&amp;blog=21440216&amp;post=210&amp;subd=burcudo&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t remind myself starting to code, even a single tiny function, without illustrating it on paper. <em>Do I write code on paper?</em> Yes, I also do that. I adore coding on whiteboards where many people can come together on a coffee break and discuss. Most of the young developers ignore that single rule in software development. To write decent code, you have to spend <strong>more time on thinking, criticising, brainstorming</strong> – determining what the problem is before getting into the solution. Defining the constraints, getting aware of the exceptions, and so on.</p>
<h2>Early Starting or Deep Thinking?</h2>
<p>I wish the first idea comes to mind was the perfect one. But usually, it is not even close enough to be a good solution – it is often greedy and very straight-forward. The more you learn about the problem and its characteristics, the better and more efficient solution will pop up. If you start coding in the first hour, you will probably never ever finish the task. I&#8217;d like to share a case study from Jon Bentley&#8217;s amazing book, <a href="http://www.amazon.com/Programming-Pearls-2nd-ACM-Press/dp/0201657880">Programming Pearls</a>.</p>
<p>The story is about Andrew Appel and his experience on reducing the run time of a system from <strong>one year to one day</strong>. They had to simulate the motions of <em>N objects</em> in 3D space, given their masses and initial positions and velocities. They basically were interested to predict the positions of planets, stars, galaxies 10 years, 100 years, 1000 years later. In a 2D space the input may look like the image on the left: a large set of vectors.</p>
<p>The regular simulation programs divide time into small steps and computes the progress of each object at each step. Due to the existing of gravitational field and mass attractions, the computational cost were proportional to N<sup>2</sup>. Appel estimated that 1000 time steps of such a system with <em>N=10000</em> objects would require more than one year on a VAX-11/780 or a day on a <a href="http://en.wikipedia.org/wiki/Cray-1">Cray-1</a>. Andrew had to develop a system far more efficient than a one-year-running turtle. After several speedup improvements, he reduced the runtime to less than a day on VAX-11/780 &#8212; almost 400 times faster than the initial setup.<span id="more-210"></span></p>
<p>He managed to change the concept on many levels to make such a huge difference.</p>
<ol>
<li><strong>Data Structures:</strong> Foremost, O(<em>N<sup>2</sup></em>) had to go. He decided to represent objects as leaves on a binary tree; higher nodes were representing the cluster of objects. The force operating on a particular object can be approximated  by the force exerted by the large clusters. This alone reduced complexity to O(<em>N logN</em>) by a factor of <em>12</em>.</li>
<li><strong>Algorithm Tuning:</strong> Initial algorithm has to use tiny time steps to handle the rare case that two particles come closer to one another. Usages of tree-based structure enabled investigation of such rare cases possible<em> independently from time steps</em>. As a result, Andrew doubled the time step size and <em>halved</em> the run time.</li>
<li><strong>Data Structure Reorganization:</strong> The tree that was representing the initial objects was quite bad in representing the later sets. Reconfiguring the tree at every new step was a bit costly but reduced the number of local calculations and <em>halved</em> the total runtime.</li>
<li><strong>Code Tuning:</strong> Due to additional numerical accuracy provided by the tree, 64-bit floating point number could be replaced by 32 bit single-precision, <em>halved</em> the runtime. Additionally, profiling the application showed that 98% percent of runtime was being spend in one procedure. Rewriting that procedure in assembly  increased the speed by a factor of <em>2,5</em>.</li>
<li><strong>Hardware Extensions:</strong> Moving the program to a similar machine with a floating point accelerator <em>halved</em> the total runtime.</li>
</ol>
<p>Finally new system was requiring only one day to simulate 10k objects. Most of the work done by Andrew Appel were visible without writing a single line of code. If your inventions don&#8217;t rely on the statistical results to be proved, you should be able to make all decisions without writing a single line of code. Being able to predict the system&#8217;s response on paper can make you the the one makes the differences.</p>
<p>Even in professional environments, people tend to start coding as soon as possible. Initial design doesn&#8217;t only lead you functional mistakes and a program with tones of bugs, but may blind you to see the problem from different aspects and representing data in a different ways to fasten the system. Only good estimators can code good software. Therefore, I&#8217;m not interested in which <strong>new fancy technologies you know</strong>, far more interested if you have <em>a wide range from top to hardware</em>, able to see the bottlenecks and improve them on paper. Then, any developer can write the code.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/burcudo.wordpress.com/210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/burcudo.wordpress.com/210/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/burcudo.wordpress.com/210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/burcudo.wordpress.com/210/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/burcudo.wordpress.com/210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/burcudo.wordpress.com/210/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/burcudo.wordpress.com/210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/burcudo.wordpress.com/210/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/burcudo.wordpress.com/210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/burcudo.wordpress.com/210/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/burcudo.wordpress.com/210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/burcudo.wordpress.com/210/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/burcudo.wordpress.com/210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/burcudo.wordpress.com/210/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=burcudogan.com&amp;blog=21440216&amp;post=210&amp;subd=burcudo&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://burcudogan.com/2009/04/18/using-paper-and-pencil-before-coding/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e7526ec3e801f8ba99f6746498a154a6?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">thejbf</media:title>
		</media:content>
	</item>
	</channel>
</rss>
