<?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>henko.net</title>
	<atom:link href="http://henko.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://henko.net</link>
	<description>Home of a human being and tech manager</description>
	<lastBuildDate>Mon, 29 Jun 2009 07:03:22 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Exception Handling Policy &#8211; Using Assertions</title>
		<link>http://henko.net/imperfection/exception-handling-policy-using-assertions/</link>
		<comments>http://henko.net/imperfection/exception-handling-policy-using-assertions/#comments</comments>
		<pubDate>Mon, 29 Jun 2009 06:00:18 +0000</pubDate>
		<dc:creator>Henrik Jernevad</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Imperfection]]></category>
		<category><![CDATA[Implementation]]></category>

		<guid isPermaLink="false">http://henko.net/?p=700</guid>
		<description><![CDATA[This is the second part in a series of four on exception handling and it focuses on an area related to exceptions &#8212; assertions.

A quick summary of posts in this series:


Throwing Exceptions
Using Assertions (this one)
Catching Exceptions
Logging Exceptions


Guidelines for assertions

An assertion is code that&#8217;s used during development that allows a program to check itself as it [...]]]></description>
			<content:encoded><![CDATA[<p>This is the second part in a series of four on exception handling and it focuses on an area related to exceptions &#8212; assertions.</p>

<p>A quick summary of posts in this series:</p>

<ol>
<li><a href="http://henko.net/imperfection/exception-handling-policy-throwing-exception/" title="Exception Handling Policy - Throwing Exceptions">Throwing Exceptions</a></li>
<li><strong>Using Assertions</strong> (this one)</li>
<li>Catching Exceptions</li>
<li>Logging Exceptions</li>
</ol>

<h3>Guidelines for assertions</h3>

<p>An <a href="http://en.wikipedia.org/wiki/Assertion_(computing)" title="assertion">assertion</a> is code that&#8217;s used during development that allows a program to check itself as it runs. They are used much in the same spirit as unit tests, but spread out in the actual program code. It is a statement placed to indicate that the developer thinks that some predicate is always true at that place.</p>

<h4>Use assertions for conditions that should never occur</h4>

<div style="margin-left: 2em;">

<p>If an assertion is fired for an anomalous condition, the corrective action is not merely to handle an error gracefully — the corrective action is to change the program&#8217;s source code, recompile, and release a new version of the software.</p>

<p>Use assertions to document and verify preconditions and postconditions.</p>

</div>

<h4>Use a barricades to distinguish between assertions and exceptions</h4>

<div style="margin-left: 2em;">

<p>Routines that are outside the barricade should use error handling because it isn&#8217;t safe to make any assumptions about the data. Routines inside the barricade should use assertions, because the data passed to them is supposed to be sanitized before it&#8217;s passed across the barricade. If one of the routines inside the barricade detects bad data, that&#8217;s an error in the program rather than an error in the data.</p>

</div>

<h4>Don&#8217;t put executable code into assertions.</h4>

<div style="margin-left: 2em;">

<p>Doing so raises the possibility that the compiler will eliminate the code when you turn off the assertions. Instead, only put boolean conditions with no side effects in your assertions.</p>

</div>

<h4>For highly robust code, assert and then handle the error any way</h4>

<div style="margin-left: 2em;">

<p>Better safe than sorry, they say.</p>

</div>

<h3>Assertions in Java</h3>

<p>For those unfamiliar with assertions, I&#8217;ll give a quick summary. Java provides the keyword <code><a href="http://java.sun.com/j2se/1.4.2/docs/guide/lang/assert.html" title="assert">assert</a></code> since version 1.4. It throws a <code>java.lang.AssertionError</code> when it fails, and has the following syntax:</p>

<pre><code>assert expression : "error message shown if expression is false";
</code></pre>

<p>Where <code>expression</code> is any boolean expression which should always be true at the point of the assertion. For example, this variable should always be greater than 0, or that collection should always be empty.</p>

<p>To enable assertions when running a program, use the Java VM <code>-ea</code> (or <code>-enableassertions</code>) switch. Assertions are always compiled in, but without this switch, the assertions are ignored by the virtual machine.</p>

<p>Tune in next week for guidelines for catching exceptions! And please do write any comments or questions you might have below.</p>
]]></content:encoded>
			<wfw:commentRss>http://henko.net/imperfection/exception-handling-policy-using-assertions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Exception Handling Policy &#8211; Throwing Exceptions</title>
		<link>http://henko.net/imperfection/exception-handling-policy-throwing-exception/</link>
		<comments>http://henko.net/imperfection/exception-handling-policy-throwing-exception/#comments</comments>
		<pubDate>Mon, 22 Jun 2009 12:06:23 +0000</pubDate>
		<dc:creator>Henrik Jernevad</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Imperfection]]></category>
		<category><![CDATA[Implementation]]></category>

		<guid isPermaLink="false">http://henko.net/?p=662</guid>
		<description><![CDATA[This is the first post in a series of four on exception handling.

The series will cover what I think is a good and sound strategy for handling exceptions and errors in your application.

It is written with Java in mind, but is applicable to most languages which feature exceptions.

A quick summary of the coming posts:


Throwing Exceptions [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/mbiskoping/510673513/"><img src="http://henko.net/wp-content/uploads/2009/06/exception.jpg" alt="An exception" title="An exception (Copyright by [martin])" width="240" height="234" class="alignright size-full wp-image-695" /></a>This is the first post in a series of four on exception handling.</p>

<p>The series will cover what I think is a good and sound strategy for handling exceptions and errors in your application.</p>

<p>It is written with Java in mind, but is applicable to most languages which feature exceptions.</p>

<p>A quick summary of the coming posts:</p>

<ol>
<li><strong>Throwing Exceptions</strong> (this one)</li>
<li><a href="http://henko.net/imperfection/exception-handling-policy-using-assertions/" title="Exception Handling Policy - Using Assertions">Using Assertions</a></li>
<li>Catching Exceptions</li>
<li>Logging Exceptions</li>
</ol>

<p>Let&#8217;s get started!</p>

<h3>General</h3>

<p>First, we&#8217;ll go through some things which apply to all types of exceptions.</p>

<h4>Always preserve the stack trace</h4>

<div style="margin-left: 2em;">

<p>Make sure that the stack trace of a wrapped exception is captured and preserved. The single worse thing one can do after eating your exceptions is to to capture it but throw away all the essential details.</p>

<p>Be careful with distributed systems, as simplistic use of Java serialization requires the Exception classes be available in all tiers.</p>

<p>Also, pre JDK 1.4 Exceptions do not preserve the stacktrace.</p>

</div>

<h4>Never use exceptions for flow control</h4>

<div style="margin-left: 2em;">

<p>Exceptions are meant for exceptional events &#8211; when things go wrong. Don&#8217;t build your system based on that something goes wrong.</p>

<p>Also, exceptions are slow, so heavy use of them might lead to performance problems.</p>

</div>

<h4>Provide enough context</h4>

<div style="margin-left: 2em;">

<p>Include information and methods in the exception which help the client deal with the exception.</p>

<p>When defining a new exception don&#8217;t just add a new error message, provide enough context for a catcher to gracefully handle the exception. If an existing exception class doesn&#8217;t have essential context, create a custom one.</p>

</div>

<p>Next, we&#8217;ll discuss checked and unchecked exceptions, and when to use them.</p>

<h3>Checked exceptions</h3>

<p>A checked exception is a Java concept which means an exception which is specified in a method&#8217;s signature. It is a way for the designer to tell the client of a method what might go wrong, so that the client can prepare accordingly.</p>

<h4>Throw a checked exception if a method can&#8217;t fulfill it&#8217;s contract</h4>

<div style="margin-left: 2em;">

<p>Either that, or don&#8217;t promise things you cannot keep.</p>

</div>

<h4>Make your exceptions part of your contract</h4>

<div style="margin-left: 2em;">

<p>Throw an exception which is meaningful in terms of the method&#8217;s contract.</p>

<p>Declare unchecked exceptions in the throws clause &#8211; make it easy for programmers and the IDE to discover the RuntimeExceptions that may be thrown by your method.</p>

<p>Document exceptions in Javadoc.</p>

</div>

<h4>Never let implementation-specific exceptions escalate to the higher layers</h4>

<div style="margin-left: 2em;">

<p>If the client code cannot do anything about a implementation-specific checked exception, convert it to a unchecked exception.</p>

<p>If you are confident that the business layer can take some recovery action when the implementation-specific exception occurs, convert it into a more meaningful checked exception.</p>

</div>

<h3>Unchecked exceptions</h3>

<p>Unchecked exceptions are all other exceptions, which are &#8220;unforeseen&#8221;.</p>

<h4>Prefer unchecked exceptions for all programming errors</h4>

<div style="margin-left: 2em;">

<p>If method parameters are invalid or preconditions not met, throw a unchecked exception. A client shouldn&#8217;t add exception handling code for providing invalid parameters, it should provide valid parameters!</p>

<p>Unchecked exceptions have the benefit of not forcing the client API to explicitly deal with them. They propagate to where you want to catch them, or they go all the way out and get reported.</p>

</div>

<h4>If the client cannot do anything useful, then make the exception unchecked</h4>

<div style="margin-left: 2em;">

<p>No sense in forcing the client to handle an exception it does not know how to deal with.</p>

</div>

<p>Feel free to provide any comments or thoughts below, and check back in a week for the next episode!</p>
]]></content:encoded>
			<wfw:commentRss>http://henko.net/imperfection/exception-handling-policy-throwing-exception/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Yes, Programmers Should Be &#8220;Mathematically Inclined&#8221;</title>
		<link>http://henko.net/imperfection/yes-programmers-should-be-mathematically-inclined/</link>
		<comments>http://henko.net/imperfection/yes-programmers-should-be-mathematically-inclined/#comments</comments>
		<pubDate>Wed, 01 Apr 2009 16:41:48 +0000</pubDate>
		<dc:creator>Henrik Jernevad</dc:creator>
				<category><![CDATA[Imperfection]]></category>
		<category><![CDATA[Learning]]></category>

		<guid isPermaLink="false">http://henko.net/?p=646</guid>
		<description><![CDATA[This post is a response to Jeff Atwood&#8217;s post/question on Should Competent Programmers be "Mathematically Inclined"?.

I originally intended to just comment that piece, but the sheer amount of comments made me realize that no-one would actually read it anyway. So I might as well write a response in my own blog which about as many [...]]]></description>
			<content:encoded><![CDATA[<p>This post is a response to Jeff Atwood&#8217;s post/question on <a href="http://www.codinghorror.com/blog/archives/001249.html" title="Should Competent Programmers be "Mathematically Inclined"?">Should Competent Programmers be "Mathematically Inclined"?</a>.</p>

<p>I originally intended to just comment that piece, but the sheer amount of comments made me realize that no-one would actually read it anyway. So I might as well write a response in my own blog which about as many will read but which makes me feel better. <img src='http://henko.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>

<p><a href="http://www.flickr.com/photos/origomi/58198837/"><img alt="" src="http://farm1.static.flickr.com/25/58198837_a18b8c23e7_m.jpg" title="Mathematically Inclined (Copyright 2005 by EricGjerde.)" class="alignright" width="240" height="230" /></a>I believe the answer is &#8220;yes&#8221;. I think that a competent programmer needs to be &#8220;mathematically inclined&#8221;. Not because the average programmer&#8217;s typical work includes much math such as applications in 3D, compression, and image manipulation. In those cases it is fairly obvious that a firm grasp of math is required. I believe the answer is &#8220;yes&#8221; because in my mind &#8220;mathematically inclined&#8221; also means &#8220;good at seeing patterns&#8221;, &#8220;good at identifying duplication&#8221;, &#8220;understands basic complexity theory&#8221;, or simply &#8220;good at groking thinks&#8221;. And while a good understanding of math in general is valuable, I think a solid understanding of discrete math and logic is invaluable.</p>

<p>Finally, I liked what the unnamed author mentioned in Jeff&#8217;s post wrote enough to reprint it here.</p>

<blockquote>
  <p>I run a small (4 people) web dev shop and I&#8217;m finding that younger coders haven&#8217;t had the pleasure of writing assembler or managing without library functions. I&#8217;ve always found strong math skills to be one of the most useful skills for coding, and when one has Google and a massive library of functions, one doesn&#8217;t have to be good at math to get things working, until it either breaks, has edge cases, or brings out OS or library bugs.</p>
  
  <p>Some quick examples: simplifying tricky equations to determine array indicies or memory offsets; trigonometry to help with physical calculations; mental hex/bin/dec conversion; logic equalities such as DeMorgan&#8217;s theorem.</p>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://henko.net/imperfection/yes-programmers-should-be-mathematically-inclined/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Common Conception Of Agile Missing The Point?</title>
		<link>http://henko.net/imperfection/common-conception-of-agile-missing-the-point/</link>
		<comments>http://henko.net/imperfection/common-conception-of-agile-missing-the-point/#comments</comments>
		<pubDate>Mon, 09 Mar 2009 07:00:53 +0000</pubDate>
		<dc:creator>Henrik Jernevad</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Imperfection]]></category>
		<category><![CDATA[Process]]></category>

		<guid isPermaLink="false">http://henko.net/?p=607</guid>
		<description><![CDATA[This is a bit of a rant, but I just gotta get it out of my system.

I&#8217;m getting frustrated by people I talk to who seem to misunderstand the whole point of agile software development (IMHO).

Different ways of reducing risk

The point with agile, as far as I understand, is to reduce risk and thereby costs [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/gibbons/2171091952/"><img alt="Missing the mark" src="http://farm3.static.flickr.com/2193/2171091952_b281d3ec41_m.jpg" title="Missing the mark (Copyright 2008 by Bah Humbug)" class="alignright" width="240" height="161" /></a>This is a bit of a rant, but I just gotta get it out of my system.</p>

<p>I&#8217;m getting frustrated by people I talk to who seem to misunderstand the whole point of agile software development (IMHO).</p>

<h3>Different ways of reducing risk</h3>

<p>The point with agile, as far as I understand, is to reduce risk and thereby costs by <a href="http://henko.net/imperfection/minimizing-irreversible-actions/" title="Minimizing Irreversible Actions">postponing decisions</a> until we have as much information as possible. In older waterfall processes, pretty much everything was decided upfront. That wasn&#8217;t because people thought it was so much fun to decide everything up front, but because they believed it to be the best way to reduce risk and cost. Because a bug found just before delivery <em>is</em> <a href="http://www.agilemodeling.com/essays/costOfChange.htm" title="much more costly">much more costly</a> than one found earlier.</p>

<p>Agile, on the other hand, tries to use development practices which enable us to postpone decisions, practices which makes the system easy to change even later in the development process. Thus, the code you write should have two qualities:</p>

<ul>
<li>doesn&#8217;t force you into making unnecessary decisions, and</li>
<li>be easy to change.</li>
</ul>

<h3>How to reduce risk the agile way</h3>

<p>Quotes such as &#8220;<a href="http://c2.com/xp/YouArentGonnaNeedIt.html" title="You Ain't Gonna Need It">You Ain't Gonna Need It</a>&#8221; (YAGNI) and &#8220;<a href="http://c2.com/xp/DoTheSimplestThingThatCouldPossiblyWork.html" title="Do The Simplest Thing That Could Possibly Work">Do The Simplest Thing That Could Possibly Work</a>&#8221; (DTST) emphasize the first part &#8212; not making premature decisions. But while you can typically find people talking about the second part too, it doesn&#8217;t nearly get as much attention in people minds as the first one. Most likely simply because it&#8217;s not included in the name, in the mantra. I guess &#8220;You Aren&#8217;t Gonna Need It, But Do Not Forget To Make Sure Your Code Is Flexible&#8221; just doesn&#8217;t stick as easily.</p>

<p>Actually ensuring that your code is easy to change requires some work &#8212; especially while trying to avoid making premature decisions! It means using things like table driven code and putting abstractions in code an meta-data in configuration. It means thinking about what things are likely to change, and what things are not. It means not assuming too much, since you never know how things are going to be used in the future.</p>

<h3>Where many people misunderstand agile</h3>

<p>Rules and practices are good, but they are just the means to an end. I find that too many people interpret the agile mantras of YAGNI and DTST too literally. They create solutions which are &#8220;simple&#8221; and &#8220;works&#8221; and only includes &#8220;what&#8217;s needed&#8221;.</p>

<p>However, the next day, or next month, when requirements and expectations have changed (as they no doubt will) these solutions prove to be hard to adapt to the new situation. That&#8217;s because their developers forgot about the second part, making the system easy to change! And I believe forgetting that is forgetting the very core of what agile is about!</p>

<p>You agree? Got another opinion? How do you ensure you&#8217;re code is easy to change?</p>
]]></content:encoded>
			<wfw:commentRss>http://henko.net/imperfection/common-conception-of-agile-missing-the-point/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Den laglydige taxichauffören</title>
		<link>http://henko.net/imperfection/den-laglydige-taxichaufforen/</link>
		<comments>http://henko.net/imperfection/den-laglydige-taxichaufforen/#comments</comments>
		<pubDate>Sun, 22 Feb 2009 12:05:29 +0000</pubDate>
		<dc:creator>Henrik Jernevad</dc:creator>
				<category><![CDATA[Imperfection]]></category>
		<category><![CDATA[Solution]]></category>

		<guid isPermaLink="false">http://henko.net/?p=522</guid>
		<description><![CDATA[&#8212; en berättelse som inte har något med rättegången kring the Pirate Bay att göra

Låt oss föreställa oss en helt vanlig taxichaufför.

Taxichauffören har taxilicens och en taxibil som är registrerad enligt konstens alla regler. Det enda som utmärker vår taxichaufför är att han har en lite egen twist &#8212; han tar alla körningar och ställer [...]]]></description>
			<content:encoded><![CDATA[<h3>&mdash; en berättelse som inte har något med rättegången kring the Pirate Bay att göra</h3>

<p><strong>Låt oss föreställa oss en helt vanlig taxichaufför.</strong></p>

<p><img src="http://henko.net/wp-content/uploads/2009/02/pirate-taxi-150x150.png" alt="Taxi with crossbones" title="Taxi with crossbones" align="right" width="150" height="150" class="size-thumbnail wp-image-544" />Taxichauffören har taxilicens och en taxibil som är registrerad enligt konstens alla regler. <strong>Det enda som utmärker vår taxichaufför är att han har en lite egen twist &mdash; han tar alla körningar och ställer inga frågor.</strong></p>

<p>En dag får vår taxichaufför ett uppdrag: Kör till en given adress, vänta med motorn igång och kör därefter till en annan adress. Taxichauffören accepterar. Väl vid den första adressen ser han att det är en bank. Han ser också klart och tydligt hur hans passagerare är inne i banken, hotar personalen och tvingar dem att ge honom pengar. Men vår taxichaufför ställer ju inga frågor så han väntar tills passageraren är klar på banken och kör sedan passageraren till den andra adressen. Körningen är klar och taxichauffören åker hem. <strong>Han inser att han just kört en bankrånare till och från ett rån men är okay med det &mdash; <em>han själv</em> gör ju inget olagligt. Han kör ju bara taxi.</strong></p>

<p>Efter denna incident återkommer både denna passagerare och andra personer som använder taxichauffören för att köra dem till och från rån, inbrott, stölder och andra brott. Taxichauffören fortsätter köra utan att ställa några frågor. Han får inte någon del av bytet utan tar endast ordinarie taxa. <strong>Han är medveten om att hans passagerare begår brott, men sover ändå gott om natten &mdash; <em>han själv</em> gör ju inget olagligt. Han kör ju bara taxi.</strong></p>

<p>Vad tycker du om taxichauffören? Gör han något olagligt? Beter han sig omoraliskt? Kommentera och ge din åsikt!</p>

<hr/>

<p><strong>PS.</strong> Angående något <em>helt</em> annat, Pirate Bay-rättegången pågår. Vad handlar den om egentligen? <strong>Pirate Bay-killarna gör ju inget olagligt. De driver ju bara en webbsajt.</strong> (Eller?)</p>

<p><a href="http://spotify.com"><img src="http://www.spotify.com/wp-content/themes/spotify/images/logo.png" align="right" width="54" alt="Spotify logo" style="border: 0" /></a>
<strong>PPS.</strong> Skivbolagen behöver tänka om! Stöd <a href="http://spotify.com" title="Spotify">Spotify</a> och andra lagliga alternativ och tala om för skivbolagen vad ni vill ha!</p>

<p><strong>PPPS.</strong> Detta inlägg är ej avsett för barn, då de <a href="http://www.tryggabarn.nu/barn/Page13083.html" title="ej förstår ironi">ej förstår ironi</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://henko.net/imperfection/den-laglydige-taxichaufforen/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Säkerhetshål på GP.se</title>
		<link>http://henko.net/imperfection/sakerhetshal-pa-gpse/</link>
		<comments>http://henko.net/imperfection/sakerhetshal-pa-gpse/#comments</comments>
		<pubDate>Tue, 03 Feb 2009 09:52:02 +0000</pubDate>
		<dc:creator>Henrik Jernevad</dc:creator>
				<category><![CDATA[Imperfection]]></category>

		<guid isPermaLink="false">http://henko.net/?p=504</guid>
		<description><![CDATA[

En kollega till mig surfade runt på gp.se och lekte med deras TV-spelare. I adressfältet fick han fick syn på en parameter vid namn insertUrl vilket genast fick honom att fundera.

Phishing

Misstanken var logiskt nog att man då kanske kunde visa inte bara GP-TV genom gp.se utan vilken sida som helst. Denna misstanke visade sig vara [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://henko.net/wp-content/uploads/2009/02/gptv.jpg"><img src="http://henko.net/wp-content/uploads/2009/02/gptv2.jpg" alt="GP.se är sårbar för XSS-attacker!" title="GP.se är sårbar för XSS-attacker!" width="422" height="169" class="size-full wp-image-511" style="border: 0" /></a></p>

<p>En kollega till mig surfade runt på gp.se och lekte med deras TV-spelare. I adressfältet fick han fick syn på en parameter vid namn <code>insertUrl</code> vilket genast fick honom att fundera.</p>

<h3>Phishing</h3>

<p>Misstanken var logiskt nog att man då kanske kunde visa inte bara GP-TV genom gp.se utan vilken sida som helst. Denna misstanke visade sig vara helt berättigad. Man kunde alltså få gp.se att visa vilken annan sida som helst inuti en iframe. Och att från en annan sida bryta sig ur en iframe:n är en barnlek. <a href="http://en.wikipedia.org/wiki/Phishing" title="Phishing">Phishing</a>-attack, ja tack!</p>

<h3>Cross-site scripting</h3>

<p>Alright, inte snyggt, men det tar inte slut där. Utöver att de blint litar på den URL som användaren skickar in och glatt visar den i sin iframe, så hade GP gjort ett ännu grövre fel. De hade över huvud taget inte validerat sin indata. Detta är ett av de mest grundläggande säkerhetsfel man över huvud taget kan göra på en webbsida. Det ger en elak person möjligheten att köra valfri kod (html/css/javascript/activex etc) när en användare besöker sidan.</p>

<p>Allt anfallaren behöver göra är att få besökarna att klicka på en specialkonstruerad länk till gp.se. Denna typ av attack kallas <a href="http://en.wikipedia.org/wiki/Cross-site_scripting" title="Cross-site Scripting">Cross-site Scripting</a> (XSS) och kan leda till exempelvis stöld av de konton som finns på gp.se, exempelvis administratörer eller annonsörer. Inte bra! Inte det minsta bra!</p>

<h3>Kontakt med webmaster</h3>

<p><a href="http://www.bloggjakt.se/goteborgs-posten-sarbara-for-cross-site-scripting/" title="Min kollega">Min kollega</a> valde att kontakta GP:s webmaster och påpeka säkerhetsbristen, så att de skulle kunna åtgärda den. Detta gjorde han igår kväll och idag under förmiddagen fick han ett svar att de nu hade åtgärdat problemet. Dock fanns i svaret inte en tillstymmelse till tack. Det kan man ju tycka att de kunde kostat på sig.</p>

<h3>Problemet finns kvar!</h3>

<p>Efter en snabb titt på samma sida kunde vi konstatera att förvisso har de nu en kontroll på <code>insertUrl</code>-argumentet för att försäkra sig om att det är en giltig GP-TV-url, men att säkerhetshålet trots detta kvarstod. Det finns nämligen fler parametrar vars värde också sätts rakt in i HTML-koden som skickas ut till användaren. Så de är fortfarande precis lika sårbara för XSS-attacker!</p>

<h3>Sammanfattning</h3>

<p>Så summa summarum, GP lyckas skapa en sida som inte bara lider av ett stort säkerhetsproblem, utan två! Två problem som är fullständigt grundläggande när det gäller säkerhet på webben. När vi påpekar det för dem svarar de kallt att det är fixat&#8230; men problemet kvarstår!</p>

<p>Jag är egentligen inte ett fan av &#8220;<a href="http://en.wikipedia.org/wiki/Full_disclosure" title="full disclosure">full disclosure</a>&#8221; gällande säkerhetsbrister, men det finns en gräns! När de helt lyckas missa grundläggande säkerhetshål inte bara en gång utan även en andra gång efter att fått information om att hålet existerar, då har de gått över den gränsen!</p>
]]></content:encoded>
			<wfw:commentRss>http://henko.net/imperfection/sakerhetshal-pa-gpse/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Cross-Functional Teams</title>
		<link>http://henko.net/imperfection/cross-functional-teams/</link>
		<comments>http://henko.net/imperfection/cross-functional-teams/#comments</comments>
		<pubDate>Mon, 17 Nov 2008 07:00:43 +0000</pubDate>
		<dc:creator>Henrik Jernevad</dc:creator>
				<category><![CDATA[Imperfection]]></category>
		<category><![CDATA[Process]]></category>

		<guid isPermaLink="false">http://henko.net/?p=381</guid>
		<description><![CDATA[A buzz word within the Agile camp is &#8221;cross-functional teams&#8221;. For some reason though, there seems to be quite some confusion about what it really means. More precisely, it seems that some people argue for that members of a cross-functional teams should be generalists rather than specialists, that everyone should be able to do every [...]]]></description>
			<content:encoded><![CDATA[<p>A buzz word within the Agile camp is &#8221;cross-functional teams&#8221;. For some reason though, there seems to be quite some confusion about what it really means. More precisely, it seems that some people argue for that members of a cross-functional teams should be generalists rather than specialists, that everyone should be able to do every job. Other argue the opposite.</p>

<h3>Definitions</h3>

<p><a href="http://en.wikipedia.org/wiki/Cross-functional_team" title="According to Wikipedia">According to Wikipedia</a>, a cross-functional team is:</p>

<blockquote>
  <p>A group of people with different functional expertise working toward a common goal. It may include people from finance, marketing, operations, and human resources departments. Typically, it includes employees from all levels of an organization.</p>
</blockquote>

<p>If we instead look at the definition of a cross-functional team in Wikipedia&#8217;s <a href="http://en.wikipedia.org/wiki/Agile_software_development" title="Agile Software Development">Agile Software Development</a> article, we learn that such a team &#8220;is usually cross-functional and self-organizing without consideration for any existing corporate hierarchy or the corporate roles of team members.&#8221; This seems to suggest that the meaning of cross-functional in agile is often interpreted a bit differently.</p>

<h3>Why confusion arises</h3>

<p>Part of the problem might be that leaders in the field are sometimes a bit unclear. For example, reading Henrik Kniberg&#8217;s otherwise excellent piece on <a href="http://blog.crisp.se/henrikkniberg/2007/05/07/1178493480000.html" title="agile testing">agile testing</a> quickly, you can easily get the perception that he is arguing for the generalist approach. Quotes such as the following certainly helps one reaching such a conclusion.</p>

<blockquote>
  <p>In agile projects, testing is considered to be far too important to be confined to a single role, a single team, or a single project phase. Having a role called Tester implies that others don&#8217;t need to test. In an agile project almost everyone tests.</p>
</blockquote>

<p>On the other hand, if you read it more carefully, he is actually arguing for a specialist approach. (Although he plays safe &#8212; and increases confusion &#8212; by calling them generalizing specialists.) Anyhow, this quote gives a rather other feeling than the previous.</p>

<blockquote>
  <p>Since the programmers have automated all the boring, repetetive tests, you are free to focus on the hard stuff. The stuff that is difficult to automate. Exploratory testing. Usability testing. Performance test scripts. Figuring out those tricky test cases that only a veteran like you could come up with.</p>
</blockquote>

<p>Finally, in his own words:</p>

<blockquote>
  <p>Agile teams are cross functional, they are made up of generalizing specialists. People who are experts at certain areas, but have basic knowledge of a whole bunch of other areas as well. A team of generalizing specialists is extremely fast at learning and adapting.</p>
</blockquote>

<h3>Why specialists?</h3>

<p>For me, I&#8217;m in the specialists camp. As some form of evidence, I&#8217;d like to quote Marcus Buckingham and Curt Coffman from the great book <a href="http://www.amazon.com/gp/product/0684852861?ie=UTF8&#038;tag=henkonet-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0684852861">First, Break All the Rules</a><img src="http://www.assoc-amazon.com/e/ir?t=henkonet-20&#038;l=as2&#038;o=1&#038;a=0684852861" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />.</p>

<blockquote>
  <p>Great managers do not believe that a productive team has camaraderie as its cornerstone and team members who can play all roles equally well. On the contrary, they define a productive team as one where each person knows which role he plays best and where he is cast in that role most of the time. &#8230; The founding principle here is that excellent teams are built around individual excellence.</p>
</blockquote>

<p>The nice part about this last quote is that it is not simply anecdotal &#8220;evidence&#8221;, but actually conclusions drawn by the Gallup organization after interviewing over 80 000 managers!</p>

<h3>Your experience?</h3>

<p>What&#8217;s your experience in the matter? Is specialist or generalist the way to go?</p>
]]></content:encoded>
			<wfw:commentRss>http://henko.net/imperfection/cross-functional-teams/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Join a Proud Minority, Read Books</title>
		<link>http://henko.net/imperfection/join-a-proud-minority-read-books/</link>
		<comments>http://henko.net/imperfection/join-a-proud-minority-read-books/#comments</comments>
		<pubDate>Mon, 10 Nov 2008 07:00:30 +0000</pubDate>
		<dc:creator>Henrik Jernevad</dc:creator>
				<category><![CDATA[Imperfection]]></category>
		<category><![CDATA[Learning]]></category>

		<guid isPermaLink="false">http://henko.net/?p=312</guid>
		<description><![CDATA[A few days ago, I a girl caught my attention on the tram. Now, a lot of girls catch my attention, but this time it wasn&#8217;t actually the girl herself but her shoulder bag which caught my attention. It happened to have a print which I thought was pretty funny.


  Join a proud minority [...]]]></description>
			<content:encoded><![CDATA[<p><script type='text/javascript' language='javascript' charset='utf-8' src='http://s3.polldaddy.com/p/1049315.js'></script><noscript> <a href='http://answers.polldaddy.com/poll/1049315/'>View Poll</a></noscript></p>

<p>A few days ago, I a girl caught my attention on the tram. Now, a lot of girls catch my attention, but this time it wasn&#8217;t actually the girl herself but her shoulder bag which caught my attention. It happened to have a print which I thought was pretty funny.</p>

<blockquote>
  <p>Join a proud minority &#8212; read books.</p>
</blockquote>

<p>First I thought that was rather witty, but then it actually made me sad. Are people who read books (by free will) actually a minority? If I restrict myself to the software development world, then apparently they are. According to DeMarco and Lister in <a href="http://www.amazon.com/gp/product/0932633439?ie=UTF8&#038;tag=henkonet-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0932633439">Peopleware</a>:<img src="http://www.assoc-amazon.com/e/ir?t=henkonet-20&#038;l=as2&#038;o=1&#038;a=0932633439" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /></p>

<blockquote>
  <p>The statistics about reading are particularly discouraging: The average software developer, for example, doesn&#8217;t own a single book on the subject of his or her work, and hasn&#8217;t ever read one. That fact is horrifying for anyone concerned about the quality of work in the field.</p>
</blockquote>

<p>Consider if this would have been some other field, say medicine. Would you have liked to hear your surgeon say, &#8220;nah, I don&#8217;t really read books, I base most of what I do on reading blogs&#8221;. I sure wouldn&#8217;t!</p>

<h3>Why you should read books</h3>

<p>Alright, why should you read books? Why not just read blogs? Good question! And here&#8217;s why:</p>

<p><strong>Books are better than blogs!</strong></p>

<p>Now, that&#8217;s a pretty tough argument. Of course, I&#8217;m not saying that blogs are bad, but what I am saying is that so much more work has been put into the really great books than into any blog out there. Don&#8217;t waste all that work! By reading books, you will learn stuff you otherwise wouldn&#8217;t have and you&#8217;ll get a deeper understanding of it.</p>

<p>Now, don&#8217;t get me wrong. Blogs are truly essential and a great part of the internet. All programmers should consider themselves very lucky for having access to all that material. However, their content is typically only good after a couple of loops in the echo chamber (aka blogosphere). When you buy a (good) book, the material you get is already refined, it has already gone through all that necessary editing.</p>

<h3>When not to buy books</h3>

<p>You might ask yourself, why should I buy books which will be outdated in a year anyway? Also, there are no hyperlinks in books. Books suck! Well, in this regard, I completely agree. The answer is:</p>

<p><strong>Don&#8217;t buy reference books.</strong></p>

<p>Here I&#8217;m going to quote Jeff Atwood, because he <a href="http://www.codinghorror.com/blog/archives/001108.html" title="explained it">explained it</a> very nicely.</p>

<blockquote>
  <p>The best programming books are timeless. They transcend choice of language, IDE, or platform. They do not explain how, but why. If you feel compelled to clean house on your bookshelf every five years, trust me on this, you&#8217;re buying the wrong programming books.</p>
</blockquote>

<h3>How about you?</h3>

<p>So, that&#8217;s my thoughts on the subject. What do you think? Do you read books? What is the best book you&#8217;ve read? The worst? Why? Answer with a comment!</p>
]]></content:encoded>
			<wfw:commentRss>http://henko.net/imperfection/join-a-proud-minority-read-books/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>People Who Are Smarter Than I Am</title>
		<link>http://henko.net/imperfection/people-who-are-smarter-than-i-am/</link>
		<comments>http://henko.net/imperfection/people-who-are-smarter-than-i-am/#comments</comments>
		<pubDate>Mon, 03 Nov 2008 07:00:54 +0000</pubDate>
		<dc:creator>Henrik Jernevad</dc:creator>
				<category><![CDATA[Imperfection]]></category>
		<category><![CDATA[Learning]]></category>

		<guid isPermaLink="false">http://henko.net/?p=330</guid>
		<description><![CDATA[I have realized that some people are smarter than I am. It is a painful realization but I just can&#8217;t ignore the evidence any longer. Allow me to explain.



I often get inspiration to write posts from reading books or blogs by really smart people. Thus, I often refer to people who are smarter than me. [...]]]></description>
			<content:encoded><![CDATA[<p>I have realized that some people are smarter than I am. It is a painful realization but I just can&#8217;t ignore the evidence any longer. Allow me to explain.</p>

<p><a href="http://flickr.com/photos/nelsonlai/1258727102/"><img src="http://henko.net/wp-content/uploads/2008/11/1258727102_3a89581878_m1.jpg" alt="Sign: No understanding at any time." title="No understanding (Image copyright by Nelson Lai)" class="alignright size-medium wp-image-362" /></a></p>

<p>I often get inspiration to write posts from reading books or blogs by really smart people. Thus, I often refer to people who are smarter than me. Sometimes I&#8217;m lucky enough to get comments from these people on my posts. While I&#8217;m typically rather convinced by my own reasoning when I write the post in question, every time I get such a comment I am struck by how much smarter they are than me.</p>

<p>Recent cases where this has happened:</p>

<ul>
<li><a href="http://henko.net/imperfection/not-converging-on-an-estimate/#comment-10420" title="Mike Cohns comment">Mike Cohns comment</a> on <a href="http://henko.net/imperfection/not-converging-on-an-estimate/" title="Not Converging on an Estimate">Not Converging on an Estimate</a>:  I discussed an adaption of some advice he gave in a book. However, my adaption forced me to ignore other parts of the same advice. He pointed out that there was no problem in actually doing both parts.</li>
<li><a href="http://henko.net/imperfection/full-statement-coverage/" title="Full statement coverage">Full Statement Coverage</a>: I wondered why Ron Jeffries was writing such sloppy unit tests in <a href="http://search.atomz.com/search/?sp-q=sudoku&amp;sp-a=sp01062000&amp;sp-advanced=1&amp;sp-p=any&amp;sp-w-control=1&amp;sp-d=custom&amp;sp-date-range=-1&amp;sp-start-month=0&amp;sp-start-day=0&amp;sp-start-year=&amp;sp-end-month=0&amp;sp-end-day=0&amp;sp-end-year=&amp;sp-x=title&amp;sp-c=10&amp;sp-m=1&amp;sp-s=0" title="some of his articles">some of his articles</a>. He didn&#8217;t seem to test even half of the code he wrote. A short email conversation later I had realized that he of course wasn&#8217;t sloppy, but rather just much more clever than I was.</li>
</ul>

<p>So, I simply hadn&#8217;t understood what they meant the first time? I don&#8217;t believe it&#8217;s as simple as that. I think I did understand. Most of the time anyway. But my level of understanding just wasn&#8217;t as deep as theirs.</p>

<p>The upside is that every such moment makes me a little bit smarter! <img src='http://henko.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  Have you experienced a similar situation? What was your latest &#8220;revelation&#8221;?</p>
]]></content:encoded>
			<wfw:commentRss>http://henko.net/imperfection/people-who-are-smarter-than-i-am/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Not Converging on an Estimate</title>
		<link>http://henko.net/imperfection/not-converging-on-an-estimate/</link>
		<comments>http://henko.net/imperfection/not-converging-on-an-estimate/#comments</comments>
		<pubDate>Mon, 27 Oct 2008 06:00:06 +0000</pubDate>
		<dc:creator>Henrik Jernevad</dc:creator>
				<category><![CDATA[Imperfection]]></category>
		<category><![CDATA[Planning]]></category>

		<guid isPermaLink="false">http://henko.net/?p=234</guid>
		<description><![CDATA[In his great book User Stories Applied, Mike Cohn suggests that &#8220;the goal is for the estimators to converge on a single estimate.&#8221; While discussing this with a senior product owner at a major Swedish telco (guess which one!), I came to realize that there might be a point in not converging on a single [...]]]></description>
			<content:encoded><![CDATA[<p>In his great book <a href="http://www.amazon.com/gp/product/0321205685?ie=UTF8&#038;tag=henkonet-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0321205685">User Stories Applied</a><img src="http://www.assoc-amazon.com/e/ir?t=henkonet-20&#038;l=as2&#038;o=1&#038;a=0321205685" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />, Mike Cohn suggests that &#8220;the goal is for the estimators to converge on a single estimate.&#8221; While discussing this with a senior product owner at a major Swedish telco (guess which one!), I came to realize that there might be a point in <em>not</em> converging on a single estimate when doing time estimation.</p>

<div class="alignmiddle">
<a href="http://flickr.com/photos/dcassaa/520211405/"><img src="http://henko.net/wp-content/uploads/2008/10/converge-300x76.jpg" alt="" title="Converge. (Image copyright by Davide Cassanello)" width="300" height="76" class="size-medium wp-image-285" /></a>
</div>

<h3>The steps</h3>

<p>I tried to perform the following steps.</p>

<ol>
<li>Define the scope of what you&#8217;re estimating.</li>
<li>As Mike Cohn suggests, ask each developer to make an estimate and write it down.</li>
<li>After everybody has made up their own mind, take note of all estimates.</li>
<li>Discuss the estimates if wanted, but do <em>not</em> revise them! (Unless someone completely misunderstood the scope.)</li>
</ol>

<p>By writing the scores down and not revising them, developers do not get a chance to influence each other. If all of these original, uninfluenced, estimates are close to each other, you can probably be more secure with that estimate. On the other hand, if they are spread out you get an indication that risk is rather high. Estimating this way actually gives you more information, as you not only get a mean value from the estimates, but also a precision or confidence interval.</p>

<h3>Related thoughts</h3>

<p>Max Pool has been arguing for <a href="http://www.codesqueeze.com/quit-sweeping-known-uncertainity-under-the-rug/" title="a similar approach">a similar approach</a>, where you estimate in ranges. However, using the approach suggested above, you don&#8217;t have to set a percentage probability yourself (which might be a hard number to come up with) &#8212; you get it for free.</p>

<p>Furthermore, if you think about it, estimating with just a single value is almost meaningless anyway &#8212; you&#8217;ve always got a precision, that is, an interval. When you say that something will take &#8220;2 days&#8221;, what is the precision? Two days within a second? Minute? Hour? Day? Week? Also, is it an upper bound? Lower bound? Mean value? Using an interval gives you a good way of making these assumptions much more explicit.</p>

<p>What are your thoughts? Have you estimated using something else than a point value? Do you disagree? Let me know!</p>

<h3>Update</h3>

<p>In his comment below, Mike Cohn pointed out that I in fact can have my cake and eat it too. I can use the highest estimate as a &#8220;upper bound&#8221; and also continue discussing and re-estimating until everybody agrees on a single estimate. That way we get a range but do not lose the valuable discussion during the convergence.</p>
]]></content:encoded>
			<wfw:commentRss>http://henko.net/imperfection/not-converging-on-an-estimate/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Minimizing Irreversible Actions</title>
		<link>http://henko.net/imperfection/minimizing-irreversible-actions/</link>
		<comments>http://henko.net/imperfection/minimizing-irreversible-actions/#comments</comments>
		<pubDate>Mon, 20 Oct 2008 06:00:11 +0000</pubDate>
		<dc:creator>Henrik Jernevad</dc:creator>
				<category><![CDATA[Imperfection]]></category>
		<category><![CDATA[Principles]]></category>

		<guid isPermaLink="false">http://henko.net/?p=173</guid>
		<description><![CDATA[Reading Lean Software Development, I stumbled upon the following quote.


  As a keynote speaker at a software conference, Enrico Zaninotto, an Italian economist, pointed out that the underlying economic mechanism for controlling complexity in just-in-time systems is minimizing irreversible actions.


The notion of &#8220;minimizing irreversible actions&#8221; strikes me as a better way of capturing that [...]]]></description>
			<content:encoded><![CDATA[<p>Reading <a href="http://www.amazon.com/gp/product/0321150783?ie=UTF8&#038;tag=henkonet-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0321150783">Lean Software Development</a><img src="http://www.assoc-amazon.com/e/ir?t=henkonet-20&#038;l=as2&#038;o=1&#038;a=0321150783" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />, I stumbled upon the following quote.</p>

<blockquote>
  <p>As a keynote speaker at a software conference, Enrico Zaninotto, an Italian economist, pointed out that the underlying economic mechanism for controlling complexity in just-in-time systems is minimizing irreversible actions.</p>
</blockquote>

<p><a href="http://flickr.com/photos/lucias_clay/2699584043/"><img src="http://henko.net/wp-content/uploads/2008/10/2699584043_a50b5056a4_m.jpg" alt="" title="Irreversible decision. (Image copyright by Lucias Clay)" width="118" height="240" class="alignright size-full wp-image-178" /></a>The notion of &#8220;minimizing irreversible actions&#8221; strikes me as a better way of capturing that whole idea than the more established &#8220;<a href="http://www.codinghorror.com/blog/archives/000705.html" title="last responsible moment">last responsible moment</a>&#8220;. The latter suggests that you should delay making decisions for as long as you can. I feel that sends the wrong signal. You can make decisions. You <em>must</em> make decisions. Not making a decision is a decision in itself. Just don&#8217;t make decisions that you cannot change &#8212; keep your options open. By thinking that you must not make decisions until the &#8220;last responsible moment&#8221;, it is easy to delay the decision longer than is actually responsible.</p>

<p>I believe this is especially true for software architecture. In the name of &#8220;last responsible moment&#8221;, many developers <a href="http://henko.net/imperfection/do-design/" title="Do design, just not Big and Up Front">avoid making architectural decisions</a>, thinking the architecture will emerge by itself. But to quote Grady Booch in a response to a letter &#8220;The Relevance of Architecture&#8221; in IEEE Software (Volume 24 Number 5).</p>

<blockquote>
  <p>Every system has an architecture; some are accidental, others intentional.</p>
</blockquote>

<p>Which is yours?</p>
]]></content:encoded>
			<wfw:commentRss>http://henko.net/imperfection/minimizing-irreversible-actions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Metaphors of Software Development</title>
		<link>http://henko.net/imperfection/metaphors-of-development/</link>
		<comments>http://henko.net/imperfection/metaphors-of-development/#comments</comments>
		<pubDate>Mon, 13 Oct 2008 06:00:30 +0000</pubDate>
		<dc:creator>Henrik Jernevad</dc:creator>
				<category><![CDATA[Imperfection]]></category>
		<category><![CDATA[Process]]></category>

		<guid isPermaLink="false">http://henko.net/?p=155</guid>
		<description><![CDATA[I&#8217;m really starting to get annoyed by people who insist on comparing creating software to building a car, and software development to an assembly line. That might have worked more or less fine with old, long forgotten(?), waterfall processes. But wake up, we don&#8217;t do software that way any more &#8212; most of us anyway.

The [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://henko.net/wp-content/uploads/2008/10/no-car1.png" alt="" title="No cars please" width="150" height="150" class="alignright" />I&#8217;m really starting to get annoyed by people who insist on comparing creating software to building a car, and software development to an assembly line. That might have worked more or less fine with old, long forgotten(?), <a href="http://henko.net/imperfection/agile-soon-considered-harmful/" title="Agile (Soon) Considered Harmful?">waterfall processes</a>. But wake up, we don&#8217;t do software that way any more &#8212; most of us anyway.</p>

<p>The problem with this comparison is that it&#8217;s simply wrong. I&#8217;m fine with comparing creating software with creating a car. But the closest thing to an assembly line in software development is the work done by build and deployment scripts, turning source code into executable software. The actual analysis, design, and coding corresponds to developing a brand new car model. It is a creative process without a single given &#8220;right answer&#8221; and of which experimentation and iteration are natural ingredients.</p>

<p>To use another metaphor, and at the same time cite <a href="http://www.poppendieck.com/" title="Mary and Tom Poppendieck">Mary and Tom Poppendieck</a> from their book <a href="http://www.amazon.com/Lean-Software-Development-Agile-Toolkit/dp/0321150783" title="Lean Software Development">Lean Software Development</a>:</p>

<blockquote>
  <p>Development is like creating a recipe, while production is like making the dish. Recipes are designed by experienced chefs who have developed an instinct for what works and the capability to adapt available ingredients to suit the occasion. Yet even great chefs produce several variations of a new dish as they iterate toward a recipe that will taste great and be easy to reproduce.</p>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://henko.net/imperfection/metaphors-of-development/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Commit message too long</title>
		<link>http://henko.net/imperfection/commit-message-too-long/</link>
		<comments>http://henko.net/imperfection/commit-message-too-long/#comments</comments>
		<pubDate>Mon, 06 Oct 2008 06:00:30 +0000</pubDate>
		<dc:creator>Henrik Jernevad</dc:creator>
				<category><![CDATA[Imperfection]]></category>
		<category><![CDATA[Process]]></category>

		<guid isPermaLink="false">http://henko.net/?p=133</guid>
		<description><![CDATA[This time, I&#8217;ll just provide a short note of insight regarding checking code into version control.

If a commit message feels very long, or you feel a resistance against writing it because you don&#8217;t know what to write, it has probably been too long since you last committed! If you commit after each task is done, [...]]]></description>
			<content:encoded><![CDATA[<p>This time, I&#8217;ll just provide a short note of insight regarding checking code into version control.</p>

<p>If a commit message feels very long, or you feel a resistance against writing it because you don&#8217;t know what to write, it has probably been too long since you last committed! If you commit after each task is done, writing a good one-sentence message is a no-brainer.</p>
]]></content:encoded>
			<wfw:commentRss>http://henko.net/imperfection/commit-message-too-long/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Better, not perfect</title>
		<link>http://henko.net/imperfection/better-not-perfect/</link>
		<comments>http://henko.net/imperfection/better-not-perfect/#comments</comments>
		<pubDate>Sun, 28 Sep 2008 20:00:32 +0000</pubDate>
		<dc:creator>Henrik Jernevad</dc:creator>
				<category><![CDATA[Imperfection]]></category>
		<category><![CDATA[Principles]]></category>

		<guid isPermaLink="false">http://henko.net/?p=122</guid>
		<description><![CDATA[My apartment is not always in perfect condition, and cleaning up that mess isn&#8217;t exactly what I look forward to. Therefore, in a discussion with a friend about this subject, I complained about that I couldn&#8217;t come up with good rules for myself on how and when to clean. (I like rules &#8212; simple, consistent, [...]]]></description>
			<content:encoded><![CDATA[<p>My apartment is not always in perfect condition, and cleaning up that mess isn&#8217;t exactly what I look forward to. Therefore, in a discussion with a friend about this subject, I complained about that I couldn&#8217;t come up with good rules for myself on how and when to clean. (I like rules &#8212; simple, consistent, and easy-to-follow rules.)</p>

<p>Every time I manage to actually do a proper cleaning of my apartment, I usually think: &#8220;Okay, now the apartment is clean, it shouldn&#8217;t be too difficult to keep it this way. I&#8217;ll just make sure that after every day it is still clean.&#8221; That&#8217;s a great rule in theory but it never works in practice. As soon as you slip, and let the apartment get messy, you&#8217;re lost. It has now become more of a mess than you can muster energy for to clean up.</p>

<h3>A different strategy</h3>

<p>But my friend suggested a different strategy: &#8220;Before you go to bed every night, make sure that the apartment is at least a little bit cleaner than it was when you woke up.&#8221; This rule has worked out extremely well for me. They both work fine as long as I follow them every single day. The difference is when I slip, when I allow the apartment to become a bit of a mess, I won&#8217;t automatically freeze and ignore it. All I have to do is to remove <em>one</em> single thing from the floor or wash <em>one</em> single glass, and I will have fulfilled my promise. If I just keep doing this, my apartment will eventually be clean. And also, once I&#8217;ve picked this single thing from the floor, or washed that single glass, it&#8217;s rather easy to take another and a third one as well.</p>

<p>When your apartment finally is clean, you&#8217;ll have to use a bit more imagination to fulfill the rule. You might archive those payed bills lying in your closet, remove the clothes you never use in your wardrobe and send them to a suitable charity, or do any other thing that you&#8217;ve long thought of doing. This would never even have happened with my first rule as it would have acknowledged my apartment as clean and I would need to do no work.</p>

<h3>In software development</h3>

<p>The reason I&#8217;m talking here about cleaning my apartment, is that I believe the very same principle applies to software development as well. It&#8217;s easy to ignore accumulating technical debt in your system, become paralyzed by it, and not have energy to deal with it. In that situation, just ensure that the system gets <a href="http://henko.net/imperfection/improve-as-you-go/" title="Improve as you go">a little better by every commit</a>, and one day, you&#8217;ll realize that your system is really in quite nice shape. So don&#8217;t aspire to be perfect, just to become better every day and you&#8217;ll get there (or at least very close <img src='http://henko.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  ).</p>
]]></content:encoded>
			<wfw:commentRss>http://henko.net/imperfection/better-not-perfect/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Agile (Soon) Considered Harmful?</title>
		<link>http://henko.net/imperfection/agile-soon-considered-harmful/</link>
		<comments>http://henko.net/imperfection/agile-soon-considered-harmful/#comments</comments>
		<pubDate>Sun, 21 Sep 2008 19:47:47 +0000</pubDate>
		<dc:creator>Henrik Jernevad</dc:creator>
				<category><![CDATA[Imperfection]]></category>
		<category><![CDATA[Process]]></category>

		<guid isPermaLink="false">http://henko.net/?p=125</guid>
		<description><![CDATA[In the nineties, software development was conceptually simple and straight-forward; you gathered requirements for the system, designed it, built it, tested it and deployed it. This was the era of waterfall, RUP, UML, and lots of up-front design. The more details decided in advance, the less costs from changing later, and thus, the better.

Then, somewhere [...]]]></description>
			<content:encoded><![CDATA[<p>In the nineties, software development was conceptually simple and straight-forward; you gathered requirements for the system, designed it, built it, tested it and deployed it. This was the era of waterfall, <acronym title='Rational Unified Process'>RUP</acronym>, <acronym title='Unified Modelling Language'>UML</acronym>, and lots of up-front design. The more details decided in advance, the less costs from changing later, and thus, the better.</p>

<p>Then, somewhere about the turn of the century, agile development became the preferred way of creating software in the more trendy corners of the development community. Today, mainstream developers have started to follow and software shops all over the place are introducing Scrum, doing test-driven development or using other agile techniques.</p>

<p>In the second edition of his popular book Code Complete, author Steve McConell describes this by saying that while he was writing the first edition, design zealots argued for “big design up-front” (BDUF), and as he was writing the second, software swamis instead argued for “emergent design”, which basically means no initial design at all. As he put it:</p>

<blockquote>In ten years the pendulum has swung from “design everything” to “design nothing”.</blockquote>

<p>Now it seems to me that the pendulum is on its way back.</p>

<p>In an article in IEEE Software, the July/August 2008 issue, Rebecca J. Wirfs-Brock argues in favor of up-front design.</p>

<blockquote>These days, some developers shy away from even suggesting that a project might need up-front design and experimentation. They equate any up-front work with “big design up front” (BDUF) and totally wasted effort. Up-front design needn’t be wasteful if you develop a design rhythm that balances thinking, learning, and doing. You’ll build confidence and sleep better at night.</blockquote>

<p>On a similar note, <a href="http://www.codethinked.com/post/2008/09/13/It-is-BDUF-not-DUF.aspx" title="Justin Etheredge argues">Justin Etheredge argues</a> that some agile developers might be a little bit naïve.</p>

<blockquote>A lot of developers think that agile development represents doing no design up front. That we will figure out what we want to do and then just jump right into coding it without any concern for what we are going to build. Then we will just come back later, refactor the whole thing, and voila, instant working application. Well, it just doesn&#8217;t work that way.</blockquote>

<p>Frans Bouma <a href="http://weblogs.asp.net/fbouma/archive/2008/09/14/is-bduf-really-bduf.aspx" title="adds to the theme">adds to the theme</a>, possibly suggesting that even laziness might be a part of it.</p>

<blockquote>Yes, Software Engineering is hard, deal with it. Don&#8217;t use the excuse that because goals are unknown, because the client changes his mind every day the design therefore has to be done in the code editor. If those are your problems, solve them, deal with them.</blockquote>

<p>My own earlier posts deal with similar issues, such as developers who do <a href="http://henko.net/imperfection/thoughtless-development/" title="Thoughtless Development">TDD without thinking</a>, and that you <a href="http://henko.net/imperfection/do-design/" title="Do design, just not Big and Up Front">can't skip design</a>.</p>

<p>To be fair to gurus arguing for the principles of agile development (which to a large degree I myself believe in), these comments apply more to average developer Joe than the gurus themselves. But then, the gurus are probably smart enough to succeed in building their software no matter what process they use. There are however way more average Joes than gurus, so the points above are still very valid.</p>

<p>Given this shift of thinking, where will we head now? Will the pendulum actually swing right back to BDUF? Will we find the sweet spot between emergent design and up-front design? Or will we rush off once again in a new chase for design nirvana? If so, where will we end up this time? I sure hope for the sweet spot option, but given human nature I’m not convinced. What are your thoughts?</p>
]]></content:encoded>
			<wfw:commentRss>http://henko.net/imperfection/agile-soon-considered-harmful/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Solution: &#8220;Specified RequestProcessor not compatible with TilesRequestProcessor&#8221;</title>
		<link>http://henko.net/imperfection/specified-requestprocessor-not-compatible-with-tilesrequestprocessor/</link>
		<comments>http://henko.net/imperfection/specified-requestprocessor-not-compatible-with-tilesrequestprocessor/#comments</comments>
		<pubDate>Fri, 09 May 2008 11:54:21 +0000</pubDate>
		<dc:creator>Henrik Jernevad</dc:creator>
				<category><![CDATA[Imperfection]]></category>
		<category><![CDATA[Solution]]></category>

		<guid isPermaLink="false">http://henko.net/?p=124</guid>
		<description><![CDATA[When using Struts 1.3 with Tiles and SSLEXT plug-ins, the application server throws an exception while trying to process a request telling you that the specified request processor isn't compatible with Tiles. Here's the solution.]]></description>
			<content:encoded><![CDATA[<h3>Problem</h3>

<p>When using Struts 1.3 with Tiles and SSLEXT plug-ins, the application server throws the following exception while trying to process a request.</p>

<pre><code>SEVERE: Allocate exception for servlet action
javax.servlet.UnavailableException: TilesPlugin : Specified RequestProcessor
        not compatible with TilesRequestProcessor
    at org.apache.struts.action.ActionServlet.init(ActionServlet.java:399)
    at javax.servlet.GenericServlet.init(GenericServlet.java:212)
    ...
</code></pre>

<h3>Cause</h3>

<p>You are using a <code>RequestProcessor</code> which does not extend <code>TilesRequestProcessor</code>, most likely <code>org.apache.struts.action.SecureRequestProcessor</code> provided by SSLEXT.</p>

<h3>Solution</h3>

<p>As stated on SSLEXT&#8217;s web page, in order to use Tiles and SSLEXT together, you need to use specific Tiles-enabled custom request processor and plug-in classes. These classes are provided by SSLEXT and their full names classes are:</p>

<ul>
<li><code>org.apache.struts.action.SecureTilesRequestProcessor</code></li>
<li><code>org.apache.struts.tiles.SecureTilesPlugin</code></li>
</ul>

<p>Note that the SSLEXT web page incorrectly states the last class&#8217; name as <code>SecureTilesPlugIn</code> (with a capital i).</p>

<h3>See also</h3>

<ul>
<li><a href="http://sslext.sourceforge.net/" title="http://sslext.sourceforge.net/">http://sslext.sourceforge.net/</a></li>
<li><a href="http://www.jroller.com/JamesGoodwill/entry/using_tiles_and_a_custom" title="http://www.jroller.com/JamesGoodwill/entry/using_tiles_and_a_custom">http://www.jroller.com/JamesGoodwill/entry/using_tiles_and_a_custom</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://henko.net/imperfection/specified-requestprocessor-not-compatible-with-tilesrequestprocessor/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Increasing sustainable pace</title>
		<link>http://henko.net/imperfection/increasing-sustainable-pace/</link>
		<comments>http://henko.net/imperfection/increasing-sustainable-pace/#comments</comments>
		<pubDate>Wed, 09 Apr 2008 08:50:31 +0000</pubDate>
		<dc:creator>Henrik Jernevad</dc:creator>
				<category><![CDATA[Imperfection]]></category>
		<category><![CDATA[Process]]></category>

		<guid isPermaLink="false">http://henko.net/?p=119</guid>
		<description><![CDATA[In the last few years, especially in the agile corners of the web, there's been quite a lot written about the 40 hour workweek, sustainable pace, no overtime, and so on. I agree with most of this stuff and think exhausted developers in the long run do more harm than good. I can't help to wonder, however, what's so magical about 40 the hour workweek? Why not 35, 45, or even 55? Just playing safe on 40 seems a waste, if my team can do better.]]></description>
			<content:encoded><![CDATA[<p><img src="http://henko.net/wp-content/uploads/2008/04/sustainable-pace.png" alt="" title="" align="right" style="margin: 0.5em 0 0.5em 1em;" />In the last few years, especially in the agile corners of the web, there&#8217;s been quite a lot written about the 40 hour workweek, <a href="http://c2.com/cgi/wiki?SustainablePace" title="sustainable pace">sustainable pace</a>, <a href="http://www.extremeprogramming.org/rules/overtime.html" title="no overtime">no overtime</a>, and <a href="http://www.infoq.com/news/2008/02/crunch_mode_allstar_paradox" title="so on">so on</a>. I agree with most of this stuff and think exhausted developers in the long run do more harm than good.</p>

<p>I can&#8217;t help to wonder, however, what&#8217;s so magical about 40 the hour workweek? Why not 35, 45, or even 55? Also, it will naturally vary among different people. So I want to know where to draw the line. Just playing safe on 40 seems a waste, if my team can do better.</p>

<h3>The capacity model</h3>

<p>In the figure above, I&#8217;ve created a simple model for how I imagine things work. It&#8217;s pretty safe to assume that everyone has a <em>maximum</em> productivity level, over which it is simply not possible to get. I&#8217;d say this maximum is defined by the programmers talent. No matter how much experience, practice or training one gets, there&#8217;s still some basic inherent talent level which defines one&#8217;s maximum. (If nothing else, let it be the number of words per minute the developer can type.)</p>

<p>More interestingly, we&#8217;ve got a current <em>capacity</em> which is the highest amount we can currently produce without lowering quality. A sustainable pace is any pace which is below this current capacity. That is, we can keep going at this rate forever, without accumulating any technical debt. We can go above it once in a while too, in a coding crunch, but then we start accumulating technical debt. This forces us to work at a lower rate later to pay back.</p>

<h3>How do you go faster?</h3>

<p>There are at least two interesting questions in this model. First, how do you find your current capacity? I believe that question can be answered empirically by increasing development speed until developers start getting (too) tired and bugs start to slip in. The second, and more interesting, question is: how do you raise your current capacity? To answer this, we must first answer another question which is: what defines your capacity? (In the figure, this unknown entity is called <em>x</em>.) My best bet is <a href="http://stevemcconnell.com/articles/art05.htm" title="motivation">motivation</a> with a tad of discipline thrown in for good measure.</p>

<p>To sum up, my point is that while we want to achieve a sustainable pace in development, we shouldn&#8217;t have to limit ourselves to 40 hours per week. If we can hold a sustainable pace of say 45 hours per week, as opposed to 40, we gain <em>more than one month</em> of extra development time during a year! Especially in start-ups, such as where I work, 40 hours a week is a luxury one cannot afford. Large companies such as Microsoft and Google also very much rely on peoples desire for and ability to work (much) more than 40 hours per week. So the question is, how do we increase our development pace while keeping it sustainable? Is it possible? (I sure hope so.) If so, how do you do?</p>
]]></content:encoded>
			<wfw:commentRss>http://henko.net/imperfection/increasing-sustainable-pace/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Improve as you go</title>
		<link>http://henko.net/imperfection/improve-as-you-go/</link>
		<comments>http://henko.net/imperfection/improve-as-you-go/#comments</comments>
		<pubDate>Sun, 09 Mar 2008 18:42:10 +0000</pubDate>
		<dc:creator>Henrik Jernevad</dc:creator>
				<category><![CDATA[Imperfection]]></category>
		<category><![CDATA[Principles]]></category>

		<guid isPermaLink="false">http://henko.net/imperfection/improve-as-you-go/</guid>
		<description><![CDATA[Sometimes we come to situation where we need to perform a major change in our code base, one that is likely to affect more or less the whole system and that would require many man-weeks to complete. Time that we typically do not have in the condensed schedule of a modern software development project. By performing the improvement step by step, at each commit, we can amortize the time spent over the course of the project, yet ensure that it performed.]]></description>
			<content:encoded><![CDATA[<p>Sometimes we come to situation where we need to perform a major change in our code base, one that is likely to affect more or less the whole system. This might be a application-wide refactoring such as extracting business logic from the controller into the model. It can be introducing in-code documentation into a undocumented system, or introducing unit tests in a legacy system (because only system&#8217;s we&#8217;ve inherited is lacking unit tests, right?).</p>

<p>No matter exactly what task it is, we&#8217;ll assume that completing it is something that would require many man-weeks to complete. Time that we typically do not have in the condensed schedule of a modern software development project. Thus, it can be hard to motivate spending the resources that would be required to perform such a change. All to often, this leads to a situation where change is regarded as &#8220;something that should be done, but which we don&#8217;t have time for right now&#8221;. That is the same thing as &#8220;something we will never do&#8221;. Furthermore, as we typically perform the improvement in order to make the code base easier to work with in the future, we want to  prioritize the parts of the system where we spend most of our development time.</p>

<h3>A simple rule</h3>

<p>In situations like this, I suggest the following rather simple rule.</p>

<blockquote>
  <p>Every time you commit, ensure that all files in that changeset are updated to the new standard.</p>
</blockquote>

<p>Thus, if your current commit touches a controller which contains business logic, you may not commit until you&#8217;ve extracted and merged it into the model. Or if your commit touches an undocumented or untested class, you may not commit until that problem has been corrected.</p>

<h3>Rationale</h3>

<p>The rationale behind this recommendation is twofold. First, the performing the change won&#8217;t feel like a gigantic task, as it only involves modifying a couple of classes at any time. This helps to get around the &#8220;something that should be done, but which we don&#8217;t have time for right now&#8221; problem. This helps to amortize the work over the course of the project.</p>

<p>Secondly, you don&#8217;t spend time on updating files on which no one is working. This connects to the assumption that the improvement is done in order to make the code base easier to work with. Thus, as long as no one is working on a file, there is no need to make the improvement there. However, as soon as someone touches that file, it will brought up to the new standard. This is really just the <a href="http://www.codinghorror.com/blog/archives/000705.html" title="Last Responsible Moment">Last Responsible Moment</a> principle, or <a href="http://c2.com/xp/YouArentGonnaNeedIt.html" title="YAGNI">YAGNI</a>, put in a slightly different context.</p>

<p>As a bonus we reduce the risk that the change introduces bugs. This is because, as opposed to performing the change in one big go, only code on which the developer has just been working is updated. Thus, the developer is more familiar with the code and is in a better position to avoid introducing bugs by breaking non-obvious relationships and dependencies in the code. This advantage becomes more important the worse shape the code in question is in.</p>

<h3>Possible drawbacks</h3>

<p>To be fair, I should mention possible drawbacks. The major argument against this method is that the system is left in a &#8220;in between&#8221; state for an extended period of time. Depending on the type of change this could become problematic. If you&#8217;re switching from using one library to another, you might for a while be dependent on both libraries rather than any one of them. This might in turn create confusion about what library to use. Or if the system is in the middle of a major large scale refactoring, developers might in the same way be confused about the correct way to implement a feature.</p>

<p>I think that the best solution to this problem is to ensure that all developers are aware of what is happening. It&#8217;s really a question about communication within the team. Exactly how to solve this potential problem depends on the team. You can create a list of ongoing improvements which everybody can check when in doubt or when committing. You can emphasize collective ownership of the code and use pair programming to spread knowledge. Do whatever fits your team, as long as you consciously considers and manages the risk.</p>

<h3>Summing it up</h3>

<p>All in all, I think performing large scale changes in many smaller chunks is the preferred way to go. Pay off some of your <a href="http://www.martinfowler.com/bliki/TechnicalDebt.html" title="technical debt">technical debt</a> every day, rather than all of it at once. After all, to pay off your whole technical debt at once, you most likely will have to take on debt of some other kind &#8212; economical, working overtime, or implementing less new business value.</p>
]]></content:encoded>
			<wfw:commentRss>http://henko.net/imperfection/improve-as-you-go/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Story Cards on a Whiteboard</title>
		<link>http://henko.net/imperfection/story-cards-on-a-whiteboard/</link>
		<comments>http://henko.net/imperfection/story-cards-on-a-whiteboard/#comments</comments>
		<pubDate>Fri, 08 Feb 2008 09:31:07 +0000</pubDate>
		<dc:creator>Henrik Jernevad</dc:creator>
				<category><![CDATA[Imperfection]]></category>
		<category><![CDATA[Planning]]></category>

		<guid isPermaLink="false">http://henko.net/imperfection/story-cards-on-a-whiteboard/</guid>
		<description><![CDATA[I just found what might be the greatest thing since sliced bread. It is so smart, so ingenious, that it made me excited like a child on Christmas for a whole week.]]></description>
			<content:encoded><![CDATA[<p><img src="http://henko.net/wp-content/uploads/2008/02/magnetic-tape1.jpg" alt=" (The greatest thing since sliced bread.)" title=" (The greatest thing since sliced bread.)" align="right" style="margin: 0.5em 0 0.5em 1em;" />I just found what might be the greatest thing since sliced bread. It is so smart, so ingenious, that it made me excited like a child on Christmas for a whole week.</p>

<p><strong>The problem</strong>: My team had a lot of index cards which we wanted to put on a wall in order to simplify planning. We had thought about using pins, tape, magnets, and pretty much every type of device used to put a piece of paper on a wall known to man. That&#8217;s when I found it.</p>

<p><strong>The solution</strong>: Flexible and adhesive magnetic tape. Just stick a piece of tape on the back of the card. Then you can post your cards on a whiteboard and move them around all day long. Up, down, left, right, left again, rearrange. If you wanna take it down and edit it, just do it and put it right back up again. So simple, so obvious. Love it!</p>

<p>If you happen to live in Sweden, you can pick a roll up at <a href="http://www.clasohlson.se/Product/Product.aspx?id=23366413" title="Clas Ohlson">Clas Ohlson</a>. In the US, I found the same product at <a href="http://www.magnetsource.com/Consumer%20Pages/Flex_TapeOFFC.html" title="The Magnet Source">The Magnet Source</a> (see product C). They&#8217;re cheap too.</p>
]]></content:encoded>
			<wfw:commentRss>http://henko.net/imperfection/story-cards-on-a-whiteboard/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Solution: &#8220;Could not load a dependent class&#8221; when using Ant through Eclipse</title>
		<link>http://henko.net/imperfection/could-not-load-a-dependent-class-ant-eclipse/</link>
		<comments>http://henko.net/imperfection/could-not-load-a-dependent-class-ant-eclipse/#comments</comments>
		<pubDate>Mon, 21 Jan 2008 12:48:15 +0000</pubDate>
		<dc:creator>Henrik Jernevad</dc:creator>
				<category><![CDATA[Imperfection]]></category>
		<category><![CDATA[Solution]]></category>

		<guid isPermaLink="false">http://henko.net/imperfection/could-not-load-a-dependent-class-ant-eclipse/</guid>
		<description><![CDATA[When running an optional Ant task through the Eclipse Ant interface, you get an error saying a dependent class could not be loaded. However, you have found all required dependencies for the tasks you are trying to use and put them in one of the folders as specified. This might be the solution.]]></description>
			<content:encoded><![CDATA[<h3>Problem</h3>

<p>When running an optional Ant task (e.g. <code>scp</code> or <code>sshexec</code>) through the Eclipse Ant interface, you get an error similar to the one below.</p>

<pre><code>BUILD FAILED
C:\Path\To\build.xml:45: Problem: failed to create task or type scp
Cause: Could not load a dependent class com/jcraft/jsch/UserInfo
       It is not enough to have Ant's optional JARs
       you need the JAR files that the optional tasks depend upon.
       Ant's optional task dependencies are listed in the manual.
Action: Determine what extra JAR files are needed, and place them in one of:
        -C:\Path\To\Ant\Home\lib
        -C:\Path\To\User\Home\.ant\lib
        -a directory added on the command line with the -lib argument

Do not panic, this is a common problem.
The commonest cause is a missing JAR.

This is not a bug; it is a configuration problem
</code></pre>

<p>However, you have found all required dependencies for the tasks you are trying to use and put them in one of the folders as specified.</p>

<h3>Cause</h3>

<p>Although you have added the right dependencies, Eclipse might not yet know of the file(s). If this is the case, you can see this by running Ant diagnostics (<code>ant -diagnostics</code> on the command line or the <code>&lt;diagnostics&gt;</code> ant task). You will see that the dependency is listed in the appropriate &#8220;lib jar listing&#8221; but is missing in the <code>java.class.path</code> system property.</p>

<h3>Solution</h3>

<p>Go to <code>Window &gt; Preferences &gt; Ant &gt; Runtime &gt; Classpath</code>, select &#8220;Ant Home Entries (default)&#8221; and click &#8220;Add External JARs&#8230;&#8221;. Select the required dependency or dependencies and accept. Now, the selected JAR files will be loaded to the class path and the optional ant task depending on them will work.</p>
]]></content:encoded>
			<wfw:commentRss>http://henko.net/imperfection/could-not-load-a-dependent-class-ant-eclipse/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Thoughtless Development</title>
		<link>http://henko.net/imperfection/thoughtless-development/</link>
		<comments>http://henko.net/imperfection/thoughtless-development/#comments</comments>
		<pubDate>Fri, 23 Nov 2007 10:25:54 +0000</pubDate>
		<dc:creator>Henrik Jernevad</dc:creator>
				<category><![CDATA[Imperfection]]></category>
		<category><![CDATA[Process]]></category>

		<guid isPermaLink="false">http://henko.net/imperfection/thoughtless-development/</guid>
		<description><![CDATA[Test-Driven Development has gone from being a new idea, considered slightly crazy, to a serious development style used by many professional developers in their everyday life. However, it is a style of development which requires much discipline, or you will not realize it’s potential. In fact, you might end up doing more harm than good.]]></description>
			<content:encoded><![CDATA[<p>Test-Driven Development has gone from being a new idea, considered slightly crazy, to a serious development style used by many professional developers in their everyday life. However, it is a style of development which requires much discipline, or you will not realize it&#8217;s potential. In fact, you might end up doing more harm than good.</p>

<h3>Traditional vs Test-Driven</h3>

<p>The traditional way of developing (if there is such a thing) typically follows this pattern.</p>

<ol>
<li>Implement a feature.</li>
<li>Test follows from implementation.</li>
</ol>

<p>Whereas Test-Driven Development reverses that order.</p>

<ol>
<li>Test a (missing) feature.</li>
<li>Implementation follows from test.</li>
</ol>

<p>The idea here is that if we design and write the test before concerning ourselves with a particular implementation, we are more open-minded and the resulting feature will be designed <em>as we want to use it</em> rather than <em>how it&#8217;s easiest to implement</em>.</p>

<h3>Thoughtless Development</h3>

<p>Some people (myself included, in an earlier life), tend to get this idea slightly wrong. They end up with, what I call, <em>Thoughtless Development</em>. When converting from traditional development to TDD, they know the implementation is supposed to go last and follow from the tests.</p>

<p>For some reason though, they keep the &#8220;test follows from implementation&#8221; part. But as the test is supposed to be written first, there is no longer anything it can follow from. To make it even better, it is also supposed to be as simple as possible, which is easily interpreted as <em>easy to do</em> as possible. The flow typically ends up something like this.</p>

<ol>
<li>Test follows from (vague expectations of) implementation.</li>
<li>Implementation follows from test.</li>
</ol>

<p>Do I need to add that they typically end up with a heap of junk? That&#8217;s because there is no room for thought in this process. All the thinking and care that should go into designing tests is forgotten.</p>

<p>As I&#8217;ve written about earlier, some people tend to use TDD as an excuse for <a href="http://henko.net/imperfection/do-design/" title="Do design, just not Big and Up Front">doing no design at all</a>. Either purposefully or by accident. This is ironic, as TDD is really all about design! So let us all make sure that we are doing Test-Driven Development, and not Thoughtless Development.</p>
]]></content:encoded>
			<wfw:commentRss>http://henko.net/imperfection/thoughtless-development/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sorted collections in Hibernate</title>
		<link>http://henko.net/imperfection/sorted-collections-in-hibernate/</link>
		<comments>http://henko.net/imperfection/sorted-collections-in-hibernate/#comments</comments>
		<pubDate>Wed, 03 Oct 2007 11:29:10 +0000</pubDate>
		<dc:creator>Henrik Jernevad</dc:creator>
				<category><![CDATA[Imperfection]]></category>
		<category><![CDATA[Solution]]></category>

		<guid isPermaLink="false">http://henko.net/imperfection/sorted-collections-in-hibernate/</guid>
		<description><![CDATA[We want a collection field belonging to an entity object to be sorted. There are two possible solutions.]]></description>
			<content:encoded><![CDATA[<h3>Problem</h3>

<p>We want a collection field belonging to an entity object to be sorted.</p>

<h3>Solution</h3>

<p>There are two possible solutions:</p>

<ul>
<li>If you want the collection to be sorted when loaded, but not necessarily keep that sorting order all the time, use the <code>OrderBy</code> annotation where you set the actual <code>ORDER BY</code> SQL clause. In that case, the collection can be of any type (e.g. <code>Collection</code>).</li>
<li><p>If you want the collection to be sorted at all times, make it of type <code>SortedSet</code> or <code>SortedMap</code> and set the <code>Sort</code> annotation.</p>

<ul>
<li>If the objects in the collection implements <code>Comparable</code> set type to <code>SortType.NATURAL</code>.</li>
<li>Otherwise set it to <code>SortType.COMPARATOR</code> and specify your own <code>Comparator</code> class in the <code>comparator</code> attribute.</li>
</ul></li>
</ul>

<h3>Remarks</h3>

<ul>
<li>There exists an annotation with name <code>OrderBy</code> in both the <code>javax.persistence</code> package as well as the <code>org.hibernate.annotations</code> package. The former should be used.</li>
</ul>

<h3>See also</h3>

<ul>
<li><a href="http://www.hibernate.org/hib_docs/annotations/reference/en/html_single/#entity-hibspec-collection-enhance" title="Collection related annotations">Collection related annotations</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://henko.net/imperfection/sorted-collections-in-hibernate/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Constructors and Creation Methods</title>
		<link>http://henko.net/imperfection/constructors-and-creation-methods/</link>
		<comments>http://henko.net/imperfection/constructors-and-creation-methods/#comments</comments>
		<pubDate>Sat, 22 Sep 2007 12:53:36 +0000</pubDate>
		<dc:creator>Henrik Jernevad</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Imperfection]]></category>

		<guid isPermaLink="false">http://henko.net/imperfection/constructors-and-creation-methods/</guid>
		<description><![CDATA[Sometimes a constructor doesn't communicate intention very effectively. This could be because instantiating the class in question isn't as straight-forward as "creating a new object", or because there are many alternative constructors. In those circumstances it might be useful to use well-named static or non-static methods to create instances of the class instead.]]></description>
			<content:encoded><![CDATA[<p>Sometimes a constructor doesn&#8217;t communicate intention very effectively. This could be because instantiating the class in question isn&#8217;t as straight-forward as &#8220;creating a new object&#8221;, or because there are many alternative constructors. In those circumstances it might be useful to use well-named static or non-static methods to create instances of the class instead.</p>

<p><a href="http://industriallogic.com/xp/refactoring/constructorCreation.html" title="Joshua Kerievsky introduced">Joshua Kerievsky introduced</a> the term <em>Creation Method</em> for these kinds of methods. The GOF pattern <a href="http://en.wikipedia.org/wiki/Factory_method" title="Factory Method">Factory Method</a> is similar as it includes a subset of all possible <em>Creation Method</em>s.</p>

<p>So, how does a <em>Creation Method</em> differ from a constructor, semantically? When should one use one or the other?</p>

<h3>Is computation required?</h3>

<p>I tend to use a <em>Creation Method</em>s when the instance creation requires much computation. In one sense, it is very similar to when to use properties and when to use Get-methods in VB/C#.</p>

<p>Possibly, a <em>Creation Method</em> which does a lot should be seen as a separate responsibility and moved to a a separate <em>Factory</em> class. This is similar to what Joshua Kerievsky discusses in <a href="http://www.industriallogic.com/xp/refactoring/classesWithFactory.html" title="Encapsulate Classes with Factory">Encapsulate Classes with Factory</a>, that some developers might not like having a class which has a <em>Factory</em> responsibility as well as its normal responsibility. In the end, I guess it&#8217;s a matter of taste.</p>

<h3>Do you actually get a <em>new</em> object?</h3>

<p>A <em>Creation Method</em> may be used when there is a finite set of possible objects to create. In such a case, a well named <em>Creation Method</em> may indicate that you cannot actually create a <em>new</em> object, but rather get one of the already defined.</p>

<p>An example would be the Java class <a href="http://java.sun.com/javase/6/docs/api/java/nio/charset/Charset.html" title="Charset">Charset</a>. There is a limited number of possible charsets (or at least number of charsets the system will understand), and therefore it does not provide a public constructor, but rather uses the method <code>forName(String)</code>. You would use the following code to create a <code>Charset</code> object.</p>

<pre><code>Charset c = Charset.forName("ISO-8859-1");
</code></pre>

<h3>Other reasons</h3>

<p>Another reason to use a <em>Creation Method</em> could be to hide the fact that it&#8217;s actually a (private) subclass which is being instantiated. In other words, that the <em>Creation Method</em> is actually a true <em>Factory Method</em>. See for instance the Money example in Kent Beck&#8217;s <a href="http://www.amazon.com/Test-Driven-Development-Addison-Wesley-Signature/dp/0321146530" title="Test-Driven evelopment">Test-Driven evelopment</a>.</p>

<p>You&#8217;ve got more ideas on what differs <em>Creation Method</em>s and constructors? Post a comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://henko.net/imperfection/constructors-and-creation-methods/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Testability vs coupling</title>
		<link>http://henko.net/imperfection/testability-vs-coupling/</link>
		<comments>http://henko.net/imperfection/testability-vs-coupling/#comments</comments>
		<pubDate>Fri, 13 Jul 2007 09:45:19 +0000</pubDate>
		<dc:creator>Henrik Jernevad</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Imperfection]]></category>

		<guid isPermaLink="false">http://henko.net/imperfection/testability-vs-coupling/</guid>
		<description><![CDATA[I want to describe a situation I came across where designing for testability seems to be in conflict with the always-valuable principle of loose coupling.]]></description>
			<content:encoded><![CDATA[<p>I want to describe a situation I came across where designing for testability seems to be in conflict with the always-valuable principle of loose coupling.</p>

<h3>Summary of coupling</h3>

<p><a href="http://stevemcconnell.com/" title="Steve McConnell">Steve McConnell</a> in <a href="http://cc2e.com/" title="Code Complete">Code Complete</a> describes coupling as follows.</p>

<blockquote>
  <p>Coupling describes how tightly a class or routine is related to other classes or routines. The goal is to create classes and routines with small, direct, visible, and flexible relations to other classes and routines, which is known as &#8220;loose coupling&#8221;.</p>
</blockquote>

<p>McConnell furthermore lists a number of different types of coupling, some of which are better than other.</p>

<ul>
<li><em>Simple-data-parameter coupling</em>: All data passed between <em>A</em> and <em>B</em> are of primitive data types and passed through parameter lists. This kind of coupling is normal and acceptable.</li>
<li><em>Simple-object coupling</em>: <em>A</em> instantiates an object of type <em>B</em>. This kind is also fine.</li>
<li><em>Object-parameter coupling</em>: <em>A</em> requires <em>B</em> to send it an object of type <em>C</em>. This type is tighter since it requires <em>B</em> to know of <em>C</em>.</li>
<li><em>Semantic coupling</em>: <em>A</em> makes use of, not some syntactic element of <em>B</em>, but knowledge of its inner workings. Should be avoided.</li>
</ul>

<h3>Dependency injection to simplify testing</h3>

<p>So, loose coupling is definitely good as it makes the system easier to work with. However, when I read one of <a href="http://codebetter.com/blogs/jeremy.miller/archive/2006/03/09/140465.aspx" title="Jeremy Miller's excellent posts">Jeremy Miller's excellent posts</a> I started thinking. He suggests using dependency injection to simplify testing in some cases, which to me seems to be creating tighter coupling within the system.</p>

<p>More specifically, the problem he describes is as follows. A class <code>ClassUnderTest</code> internally creates an object of type <code>Dependency</code>. However, if it is hard to create a new instance of <code>Dependency</code> equal to the first one (e.g. a datetime object representing &#8220;now&#8221;), <code>ClassUnderTest</code> becomes very difficult to test.</p>

<p>When the unit test wants to create a copy of the the hard-to-reproduce-object <code>Dependency</code> to compare with <code>ClassUnderTest</code>&#8217;s <code>Dependency</code> instance, a non-equal instance is created (the system clock has changed) and the test fails.</p>

<p>The solution is to provide the object under test with either:</p>

<ul>
<li>the <code>Dependency</code> object in question itself, or </li>
<li>an object which provides <code>ClassUnderTest</code> with the wanted <code>Dependency</code> instance.</li>
</ul>

<p>I agree with this completely. In fact, I&#8217;ve had the problem a number of times myself, and solved it successfully this very way.</p>

<h3>In terms of coupling</h3>

<p>With respect to coupling, the case is that before we add the test (let&#8217;s assume we&#8217;re testing legacy code) we have <em>simple-object coupling</em>, since <code>ClassUnderTest</code> creates another object <code>Dependency</code>. However, when we test <code>ClassUnderTest</code> we want to create another object of the same type as <code>Dependency</code> equal to the one <code>ClassUnderTest</code> created.</p>

<p>As noted above, the solution is dependency injection &#8212; to provide <code>ClassUnderTest</code> with <code>Dependency</code>, either directly or indirectly. That way, we have the possibility to get hold of <code>Dependency</code> to perform the assertion in question. In terms of coupling however, this changes the coupling to be of type <em>object-parameter coupling</em> which is considered tighter than the type of coupling we had before.</p>

<h3>A counter argument</h3>

<p>Thinking about this, I thought that maybe the key here is that to test <code>ClassUnderTest</code> in the first case, the test would need to be <em>semantically coupled</em> to <code>ClassUnderTest</code> because it would have to know what kind of <code>Dependency</code> object it created internally (&#8221;now&#8221; vs any other datetime) and try to recreate it in some clever way. So we actually replace semantic coupling with object-parameter coupling &#8212; an improvement.</p>

<p>The counter argument (to the counter argument) is that without the test code, we would have no need to create such an object and there would be no semantic coupling in the first place. Thus, writing the test tightens the coupling in the system.</p>

<h3>The question</h3>

<p>Am I missing anything, or is this an example of where designing for testability actually leads to worse (as in more complex and more tightly coupled) design? Or am I just getting lost completely in theory? Maybe this slightly tighter coupling is nothing compared to what we gain from having a good and simple unit test in place.</p>
]]></content:encoded>
			<wfw:commentRss>http://henko.net/imperfection/testability-vs-coupling/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Scope control</title>
		<link>http://henko.net/imperfection/scope-control/</link>
		<comments>http://henko.net/imperfection/scope-control/#comments</comments>
		<pubDate>Thu, 21 Jun 2007 14:30:18 +0000</pubDate>
		<dc:creator>Henrik Jernevad</dc:creator>
				<category><![CDATA[Imperfection]]></category>
		<category><![CDATA[Implementation]]></category>

		<guid isPermaLink="false">http://henko.net/imperfection/scope-control/</guid>
		<description><![CDATA[Again, the book <em>Test-Driven Development: By Example</em> by Kent Beck provides me with an eye-opening experience. It explains how test-driven development is useful for scope control when developing.]]></description>
			<content:encoded><![CDATA[<p><a href="http://henko.net/imperfection/non-obvious-duplication/" title="Non-obvious duplication">Again</a>, the book <a href="http://www.awprofessional.com/bookstore/product.asp?isbn=0321146530&amp;rl=1" title="Test-Driven Development: By Example">Test-Driven Development: By Example</a> by Kent Beck provides me with an eye-opening experience. It explains how test-driven development is useful for scope control when developing.</p>

<blockquote>
  <p>Programmers are good at imagining all sorts of future problems. Starting with one concrete example and generalizing from there prevents you from prematurely confusing yourself with extraneous concerns. You can do a better job of solving the immediate problem because you are focused. When you go to implement the next test case, you can focus on that one, too, knowing that the previous test is guaranteed to work.</p>
</blockquote>

<p>I&#8217;ve found this to be very true. Before starting to think this way, I way to often started writing a test (or even started implementing some feature), only to stray away to a number of different tasks; adding guard clauses for the function, writing a helper function that I might need, refactoring a related method, and so on. By writing a simple test and implement that piece of functionality (and only that), then write a new test and implement that, and so on, my coding has become much more focused and I move forward noticeably faster.</p>

<p>However, this doesn&#8217;t mean you should just ignore thoughts on potential related problems. Write them down to look at later — but don&#8217;t let them grab your attention for longer time than that. Keep pen and paper ready at all times.</p>
]]></content:encoded>
			<wfw:commentRss>http://henko.net/imperfection/scope-control/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 1.806 seconds -->
