<?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>Martin Ankerl &#187; agile</title>
	<atom:link href="http://martin.ankerl.com/category/agile/feed/" rel="self" type="application/rss+xml" />
	<link>http://martin.ankerl.com</link>
	<description>No movement is faster than no movement</description>
	<lastBuildDate>Tue, 13 Jul 2010 05:31:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>Job Interview Question: Sorting Records</title>
		<link>http://martin.ankerl.com/2008/05/27/job-interview-question-sorting-records/</link>
		<comments>http://martin.ankerl.com/2008/05/27/job-interview-question-sorting-records/#comments</comments>
		<pubDate>Tue, 27 May 2008 11:22:36 +0000</pubDate>
		<dc:creator>Martin Ankerl</dc:creator>
				<category><![CDATA[agile]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[rant]]></category>

		<guid isPermaLink="false">http://martin.ankerl.com/?p=154</guid>
		<description><![CDATA[Dev102.com has a few postings about interesting job interview question. His fifth challenge is this neat task: You are asked to sort a collection of records. The records are stored in a file on the disk, and the size of the file is much bigger than available memory you can work with. Assume a record [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.dev102.com/">Dev102.com</a> has a few postings about interesting job interview question. <a href="http://www.dev102.com/2008/05/26/a-programming-job-interview-challenge-5-records-sorting/">His fifth challenge</a> is this neat task:</p>
<blockquote><p>You are asked to sort a collection of records. The records are stored in a file on the disk, and the size of the file is much bigger than available memory you can work with. Assume a record size is 10 bytes and file size is 1GB. you read and write data to/from disk in units of pages where each page is 1KB big. You have few (less than 10) available pages of physical memory. Assume you are given a method to compare two records.</p></blockquote>
<p>Here is how I would approach this problem. It was just a quick direct writeup of the thoughts that popped up in my mind:</p>
<ol>
<li>Easiest solution: use Unix&#8217;s <a href="http://www.softpanorama.org/Tools/sort.shtml">sort</a> tool, with <tt>-S</tt> option to specify max memory usage.
<li>If this is not allowed, the second easiest solution is to implement a simple <a href="http://en.wikipedia.org/wiki/Merge_sort">Merge sort</a>, and use multiple passes with one temporary file until everything is sorted.
<li>If speed is an issue, you can have a pre-pass before the merge sort that loads as much data junks into memory as possible, sorts this junk with <a href="http://en.wikipedia.org/wiki/Quick_Sort">Quicksort</a>, and write each sorted junk back into the temporary file.
<li>If you want to go even faster, you can go crazy with 10 passes at once and use a <a href="http://en.wikipedia.org/wiki/Sorting_network">sorting network</a> to merge these 10 streams. Here comes the point where you should benchmark before coding, because caching, harddisk properties etc. might have an enormous influence.
</ol>
<p>I believe this is a quite reasonable approach. It is important to have multiple solutions for a problem to select from, then you can choose the simplest one that works. This is the <a href="http://martin.ankerl.com/2006/01/25/software-design-principles/">Do The Simplest Thing That Could Possibly Work (DTSTTCPW)</a> &#8211; Principle. This approach is very important in test driven development, and in general a big part of the <a href="http://en.wikipedia.org/wiki/Scientific_method">scientific method</a> (see also <a href="http://en.wikipedia.org/wiki/Occam's_Razor">Occams&#8217; Razor</a>). If the simplest solution is enough, that&#8217;s great! If this is not enough, you can try again with the second simplest solution. Repeat until the problem is solved <img src='http://martin.ankerl.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>I have use this approach for a long time now, and its really productive. Never go for cool and interesting but complex solutions just because they are cool and interesting. These kind of solutions are just for your own ego. There are even <a href="http://www.codinghorror.com/blog/archives/000584.html">10 commandments for egoless programming</a>.</p>
<div style='clear:both'></div><img src="http://martin.ankerl.com/?ak_action=api_record_view&id=154&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://martin.ankerl.com/2008/05/27/job-interview-question-sorting-records/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Three Laws of Software Development</title>
		<link>http://martin.ankerl.com/2007/01/05/three-laws-of-software-development/</link>
		<comments>http://martin.ankerl.com/2007/01/05/three-laws-of-software-development/#comments</comments>
		<pubDate>Fri, 05 Jan 2007 22:45:14 +0000</pubDate>
		<dc:creator>Martin Ankerl</dc:creator>
				<category><![CDATA[agile]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[laws]]></category>
		<category><![CDATA[rant]]></category>

		<guid isPermaLink="false">http://martin.ankerl.com/?p=79</guid>
		<description><![CDATA[seecretGeek has a nice blog entry about the three laws of Software Development, inspired by Isaac Asimov&#8217;s Laws of Robotics (minor adaptations from me): A developer must write code that creates value. A developer must make their code easy to maintain, except where such expenditure will conflict with the first law. A developer must reduce [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.secretgeek.net/">seecretGeek</a> has a nice <a href="http://www.secretgeek.net/laws_3.asp">blog entry</a> about the three laws of Software Development, inspired by Isaac Asimov&#8217;s <a href="http://en.wikipedia.org/wiki/Three_Laws_of_Robotics">Laws of Robotics</a> (minor adaptations from me):</p>
<blockquote>
<ol>
<li>A developer must write code that creates value.</li>
<li>A developer must make their code easy to maintain, except where such expenditure will conflict with the first law.</li>
<li>A developer must reduce their code to the smallest size possible, as long as such reduction does not conflict with the first two laws.</li>
</ol>
</blockquote>
<p>That&#8217;s about all there is to software development. Print this out, make copies for all your coworkers, and engrave it in stone plates so that our childrens children will still be able to live by these timeless wisdoms!</p>
<div style='clear:both'></div><img src="http://martin.ankerl.com/?ak_action=api_record_view&id=79&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://martin.ankerl.com/2007/01/05/three-laws-of-software-development/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Statistical Unit Tests with ensure4j</title>
		<link>http://martin.ankerl.com/2007/01/04/statistical-unit-tests-with-ensure4j/</link>
		<comments>http://martin.ankerl.com/2007/01/04/statistical-unit-tests-with-ensure4j/#comments</comments>
		<pubDate>Thu, 04 Jan 2007 20:54:33 +0000</pubDate>
		<dc:creator>Martin Ankerl</dc:creator>
				<category><![CDATA[agile]]></category>
		<category><![CDATA[freeware]]></category>
		<category><![CDATA[ideas]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tdd]]></category>
		<category><![CDATA[ensure4j]]></category>
		<category><![CDATA[junit]]></category>
		<category><![CDATA[statistics]]></category>

		<guid isPermaLink="false">http://martin.ankerl.com/?p=78</guid>
		<description><![CDATA[As part of another project I am developing ensure4j. The syntax (see the examples here) is working quite nicely, ensure4j is already very useful for internal use. Lately I was busy adding tests that are able to verify if some code (e.g. an optimizer that uses random, like genetic algorithm, simulated annealing, &#8230;) produces the [...]]]></description>
			<content:encoded><![CDATA[<p>As part of another project I am developing <a href="http://martin.ankerl.com/2006/08/02/redesigning-junit-asserts/">ensure4j</a>. The syntax (see the examples <a href="http://martin.ankerl.com/2006/08/02/redesigning-junit-asserts/">here</a>) is working quite nicely, ensure4j is already very useful for internal use.</p>
<p>Lately I was busy adding tests that are able to verify if some code (e.g. an optimizer that uses random, like <a href="http://en.wikipedia.org/wiki/Genetic_algorithm">genetic algorithm</a>, <a href="http://en.wikipedia.org/wiki/Simulated_annealing">simulated annealing</a>, &#8230;) produces the desired in e.g. 95% of the cases (Wikipedia has <a href="http://en.wikipedia.org/wiki/Confidence_interval#Practical_example">a nice practical example</a> for confidence intervals).</p>
<h1>Example Usage</h1>
<p>Here is an example that tests the nonsense code <tt>Math.random() * 2</tt>.</p>
<pre class="brush: java;">ensure(new Experiment() {
    public double measure() {
        return Math.random() * 2;
    }
}).between(0.9, 1.1, 0.95).sample(10, 100);</pre>
<p>The code most likely does not make much sense out of context like this, so here is an explanation of what it does:</p>
<p><span id="more-78"></span></p>
<h1>Explanation</h1>
<p>In that example we want to verify that the code  returns values whose <strong>95% confidence interval is between 0.9 and 1.1</strong>. At first take <strong>10 samples</strong> to verify this. If the mean is not as expected between the interval, there is still the chance that this was just bad luck. We can take further samples (<strong>up to 1000</strong>) to rule bad luck out. When we have to take more than 1000 samples and the mean is still not in the specified  still not met, there is a very high probability that the code does not produce the desired result, so we have to fail.</p>
<p>I hope the above description is somewhat understandable. It&#8217;s no piece of cake, and there is no way to cheat around the complexity involved with that kind of statistical tests. I have tried to make the interface as clean and simple as possible, suggestions are always welcome.</p>
<h1>Open Source?</h1>
<p>I am developing ensure4j partly at work, and partly in my free time. I would like to make it open source, but I need to get the OK from my boss first.</p>
<p>ensure4j is the the only implementation I know of that uses statistical tests that can be used with JUnit. If you know something similar than this, please post!</p>
<div style='clear:both'></div><img src="http://martin.ankerl.com/?ak_action=api_record_view&id=78&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://martin.ankerl.com/2007/01/04/statistical-unit-tests-with-ensure4j/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Redesigning JUnit Asserts</title>
		<link>http://martin.ankerl.com/2006/08/02/redesigning-junit-asserts/</link>
		<comments>http://martin.ankerl.com/2006/08/02/redesigning-junit-asserts/#comments</comments>
		<pubDate>Wed, 02 Aug 2006 20:02:18 +0000</pubDate>
		<dc:creator>Martin Ankerl</dc:creator>
				<category><![CDATA[agile]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tdd]]></category>

		<guid isPermaLink="false">http://martin.ankerl.com/?p=70</guid>
		<description><![CDATA[After reading about Behaviour Driven Development, using jMock for a while, and since I am very fond of Ruby&#8216;s core class APIs, I am sure the assertations of JUnit need a major overhaul. This are the goals I have for the redesign: Make the code expressive and as readable as possbile. This means the code [...]]]></description>
			<content:encoded><![CDATA[<p>After reading about <a href="/2006/08/02/behaviour-driven-development/">Behaviour Driven Development</a>, using <a href="http://www.jmock.org/">jMock</a> for a while, and since I am very fond of <a href="http://www.ruby-lang.org/en/">Ruby</a>&#8216;s <a href="http://www.rubycentral.com/ref/">core class API</a>s, I am sure the assertations of JUnit need a major overhaul.</p>
<p>This are the goals I have for the redesign:</p>
<p><span id="more-70"></span></p>
<ul>
<li>Make the code expressive and as readable as possbile. This means the code should look like plain english.</li>
<li>Usability is more important than flexibility.</li>
<li>Allow for much more poweful checks.</li>
</ul>
<p>Usability is very important. The good thing is that it is easy to analyze how JUnit is used (download some test driven developed open source projects, grep for <tt>assertTrue</tt>, and there you have all the cases where JUnit&#8217;s asserts were not good enough <img src='http://martin.ankerl.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> )</p>
<p>I am playing around with a few ideas, and this is the API I am currently after:</p>
<h1>Assertions Example Usage</h1>
<pre class="brush: java;">public void testInt() {
  int num = 4+1;
  ensure(num).is(5);
  ensure(num).either(4, 5, 6);
  ensure(num).between(3, 10);
}

public void testDouble() {
  double val = 4 + 0.4;
  // an epsilon is mandatory when comparing double
  ensure(val).is(4.4, 0.0001);
  ensure(val).between(4.3, 4.5);
}

public void testArray() {
  int[] a = { 1, 2, 3, 4, 5 };
  ensure(a).contains(3);
  ensure(a).size().either(5, 6);
  ensure(a).contains(2, 3, 4);
  ensure(a).contains().either(3, 10, 11);
  ensure(a).contains().neither(6, 7, 9);
  ensure(a).contains().any(3, 4);
  ensure(a).contains().all(3, 4, 5);
  ensure(a).isSorted();
  ensure(a).isUnique();
}</pre>
<p>Starting point is always <tt>ensure()</tt>. You put in the actual value, then execute some operations that modify the following constraint check, then the last command is the constraint check. The last command is always the constraint check, so you can only do one check per line of code. That&#8217;s not as flexible as jMock, but it is simpler and more readable and good enough.</p>
<p>Technically all this is very doable. Probably quite a bit of work, and most likely requires a code generator since lots of code is almost the same but not reusable (e.g. arrays for primitive data types), but that&#8217;s not a problem. I have done a few simple feasibility studies and I don&#8217;t see a big problem with this interface.</p>
<p>Please tell me what you think about this!</p>
<h1>Updates</h1>
<p>From time to time I will update this page with progress reports, until I have something that is stable enough to give away.</p>
<dl>
<dt><strong>2006-08-05</strong></dt>
<dd>I have started developing this. So far I am very happy with it, its a fun project to implement <img src='http://martin.ankerl.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  I will probably create a project on sourceforge and opensource it, but I am not sure about the licence.
</dd>
</dl>
<div style='clear:both'></div><img src="http://martin.ankerl.com/?ak_action=api_record_view&id=70&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://martin.ankerl.com/2006/08/02/redesigning-junit-asserts/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Behaviour Driven Development</title>
		<link>http://martin.ankerl.com/2006/08/02/behaviour-driven-development/</link>
		<comments>http://martin.ankerl.com/2006/08/02/behaviour-driven-development/#comments</comments>
		<pubDate>Wed, 02 Aug 2006 07:55:25 +0000</pubDate>
		<dc:creator>Martin Ankerl</dc:creator>
				<category><![CDATA[agile]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://martin.ankerl.com/?p=69</guid>
		<description><![CDATA[Recently there has been quite a bit of fuss about Behaviour Driven Development. So, what is it all about? You should have a look at that presentation from Dave Astels, it is quite interesting: Presentation: &#8220;Beyond Test Driven Development: Behaviour Driven Development&#8221; You can also view and download the video here. What this is about? [...]]]></description>
			<content:encoded><![CDATA[<p>Recently there has been quite a bit of fuss about <a href="http://behaviour-driven.org/">Behaviour Driven Development</a>. So, what is it all about? You should have a look at that presentation from <a href="http://www.daveastels.com/">Dave Astels</a>, it is quite interesting:</p>
<h1>Presentation: &#8220;Beyond Test Driven Development: Behaviour Driven Development&#8221;</h1>
<p>You can also view and download the video <a href="http://video.google.com/videoplay?docid=8135690990081075324&#038;q=behaviour+driven+development">here</a>.</p>
<p><center><br />
<embed style="width:400px; height:326px;" id="VideoPlayback" type="application/x-shockwave-flash" src="http://video.google.com/googleplayer.swf?docId=8135690990081075324"> </embed><br />
</center></p>
<p><span id="more-69"></span></p>
<h1>What this is about?</h1>
<p>In short, Behaviour Driven Development can be summarized into just one sentence:</p>
<blockquote><p>Behaviour Driven Development is exactly what you are doing if you do <a href="http://www.agiledata.org/essays/tdd.html">Test Driven Development</a> right.</p></blockquote>
<p>That&#8217;s it? Yep, that&#8217;s it. Test driven Development is truely excellent in theory, but in practice it takes a long time to master. The people behind Behaviour Driven Development argue that this is due to bad naming. Language strongly influences how you think, and when you develop test-driven, you constantly talk about &#8220;tests&#8221;, &#8220;units&#8221;, &#8220;asserts&#8221; etc. If you are unexperienced this puts you in a wrong mindstate, because TDD it is not so much about testing. Here is why:</p>
<ul>
<li>
<p>When you talk about <strong>tests</strong>, you mostly think you need to validate <em>how</em> the code does something. That&#8217;s not what you should do. In fact you should not care at all how the code does someting, you should only care about <em>what</em> it does, In short, you want to know it the codes has a desired behaviour. So lets replace the word &#8220;test&#8221; with another catchy name <strong>spec</strong>. So from now on you are not writing tests to test something, but you are writing specifications for behaviours. Sweet.
</p>
</li>
<li>
<p>Everybody has a different idea what a <strong>unit</strong> is. Some think it&#8217;s a class, others think it is a tiny piece of code, others talk about an entity of code that somehow belongs together. This ambiguousness is bad, so let&#8217;s ditch it. Lets just talk about <strong>behaviours</strong>: This is independent of the structure of what you want to test, and clearly describes what you should be validating all along; if you talk about unit tests you are limiting your scope to whatever you think a unit represents. When thinking about behaviours you are free to validate what you really should.</p>
</li>
<li>
<p>The syntax of the <strong>asserts</strong> can be cleaned up quite a bit. So in <a href="http://www.ruby-lang.org/en/">Ruby</a> with <a href="http://www.ruby-doc.org/stdlib/libdoc/runit/rdoc/index.html">rUnit</a> you write <tt>assert_equals(expected, actual)</tt>, but wouldn&#8217;t it be much nicer if you could write <tt>actual.should_be expected</tt>. In fact this is exactly how it works in <a href="http://rspec.rubyforge.org/">rSpec</a>.
</p>
</li>
</ul>
<h1>What now?</h1>
<p>Behaviour Driven Development is a very recent invention, and work around this has just started. I expect that after <a href="http://rspec.rubyforge.org/">rSpec</a> we will soon see jSpec, pSpec, and lots of other tools. I hope this will change peoples mindset and allows us to <a href="http://www.answers.com/grok">grok</a> how software engineering should work more thoroughly.</p>
<div style='clear:both'></div><img src="http://martin.ankerl.com/?ak_action=api_record_view&id=69&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://martin.ankerl.com/2006/08/02/behaviour-driven-development/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
