<?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>let x=x &#187; refactor</title>
	<atom:link href="http://www.crazymcphee.net/x/tag/refactor/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.crazymcphee.net/x</link>
	<description>programming idiom and methodology</description>
	<lastBuildDate>Fri, 27 Jan 2012 09:36:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>REST-based architectural style, a big winner</title>
		<link>http://www.crazymcphee.net/x/2011/09/15/rest-based-architectural-style-a-big-winner/</link>
		<comments>http://www.crazymcphee.net/x/2011/09/15/rest-based-architectural-style-a-big-winner/#comments</comments>
		<pubDate>Thu, 15 Sep 2011 09:45:09 +0000</pubDate>
		<dc:creator>Scot Mcphee</dc:creator>
				<category><![CDATA[architecture]]></category>
		<category><![CDATA[infrastructure and frameworks]]></category>
		<category><![CDATA[technical]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[emergent design]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[patterns]]></category>
		<category><![CDATA[refactor]]></category>
		<category><![CDATA[REST]]></category>

		<guid isPermaLink="false">http://www.crazymcphee.net/x/?p=629</guid>
		<description><![CDATA[Recently been deeply stuck in building software (apart from starting my PhD part-time). A long time ago I wrote about dynamically loading Spring contexts and component discovery &#8211; this system I&#8217;ve been building is an evolution of that one. We decided to adopt an most REST-based style to integrate between our components. Now, &#8220;run-time&#8221; discovery [...]]]></description>
			<content:encoded><![CDATA[<p>Recently been deeply stuck in building software (apart from starting my <a href="http://monumentum.tumblr.com/">PhD</a> part-time). A long time ago I wrote about <a href="http://www.crazymcphee.net/x/2010/04/29/dynamically-loading-spring-contexts-from-the-classpath-at-runtime/">dynamically loading Spring contexts and component discovery</a> &#8211; this system I&#8217;ve been building is an evolution of that one. We decided to adopt an most REST-based style to integrate between our components. Now, &#8220;run-time&#8221; discovery and configuration is easy, a matter of scraping REST URLs for the resources they contain (or even, just assuming a resource URL will be available and finding out its capabilities, or even its unavailability. at run-time). We&#8217;re using this architecture in places where you&#8217;d otherwise be employing messaging-based systems or pure-Java database service layers. Now we just convert the payload to XML/JSON and POST/PUT/GET/DELETE etc to a http URL! You&#8217;d think that this would kill performance, but we&#8217;ve found the degradation to be minimal (it helps that our transactions tend to be infrequent, but large in data set size). This is a big saving on complexity for our system &#8211; the transaction boundaries nearly always relate to the http URL calls so no more heavy reliance on things like <a href="http://www.crazymcphee.net/x/2011/02/16/come-back-gavin-king-all-is-forgiven-spring-is-the-new-ejb-2-1/">XA transactions and JTA Transaction Managers</a>. We still have them, as we need them in a couple of places for the moment, but it&#8217;s no longer such a big freaking deal for us in every situation.</p>
<p>Our system has generic components which &#8220;pass off&#8221; specific knowledge of specific data sets to specific processing components, where there are not a fixed set of these specific components available to all the generic components. In classic OO design this is achieved with interfaces and many design patterns like the Visitor Pattern. In our design we&#8217;ve replaced much of the complexity of the interface with REST-based architecture. Our application has become far more modular (despite its run-time complexity). More importantly, we are at the the point where we can easily start delivering the advanced features that the business has now specified for us without introducing a massive bloat-o-burger one-size-fits-all set of &#8220;common data definitions&#8221; that are the union of all possible sub-system functionalities.  Each sub-system can have its specific features required for that data set and still satisfy the handful of generic actions it is required to support. Each of these specific features can be developed in isolation. It&#8217;s a big win for us.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.crazymcphee.net/x/2011/09/15/rest-based-architectural-style-a-big-winner/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A terrible, terrible Eclipse bug</title>
		<link>http://www.crazymcphee.net/x/2011/03/10/a-terrible-terrible-eclipse-bug/</link>
		<comments>http://www.crazymcphee.net/x/2011/03/10/a-terrible-terrible-eclipse-bug/#comments</comments>
		<pubDate>Thu, 10 Mar 2011 00:55:19 +0000</pubDate>
		<dc:creator>Scot Mcphee</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[rants]]></category>
		<category><![CDATA[technical]]></category>
		<category><![CDATA[tools and techniques]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[craftsmanship]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[poorly attempted humour]]></category>
		<category><![CDATA[refactor]]></category>
		<category><![CDATA[test driven design]]></category>
		<category><![CDATA[wizards considered harmful]]></category>

		<guid isPermaLink="false">http://www.crazymcphee.net/x/?p=610</guid>
		<description><![CDATA[I found a massive bug in Eclipse &#8211; it has a copy and paste function. In Eclipse&#8217;s defence, Intellij IDEA and Netbeans also exhibit identical broken functionality.]]></description>
			<content:encoded><![CDATA[<p>I found a massive bug in Eclipse &#8211; <em>it has a copy and paste function</em>.</p>
<p>In Eclipse&#8217;s defence, <em>Intellij IDEA</em> and <em>Netbeans</em> also exhibit identical broken functionality.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.crazymcphee.net/x/2011/03/10/a-terrible-terrible-eclipse-bug/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Throw it away and write another one</title>
		<link>http://www.crazymcphee.net/x/2010/05/30/throw-it-away-and-write-another-one/</link>
		<comments>http://www.crazymcphee.net/x/2010/05/30/throw-it-away-and-write-another-one/#comments</comments>
		<pubDate>Sun, 30 May 2010 08:47:10 +0000</pubDate>
		<dc:creator>Scot Mcphee</dc:creator>
				<category><![CDATA[architecture]]></category>
		<category><![CDATA[professional practice]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[technical]]></category>
		<category><![CDATA[tools and techniques]]></category>
		<category><![CDATA[agile]]></category>
		<category><![CDATA[ANTLR]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[craftsmanship]]></category>
		<category><![CDATA[emergent design]]></category>
		<category><![CDATA[profession]]></category>
		<category><![CDATA[refactor]]></category>
		<category><![CDATA[rewrite]]></category>
		<category><![CDATA[test driven design]]></category>

		<guid isPermaLink="false">http://www.crazymcphee.net/x/?p=557</guid>
		<description><![CDATA[Most developers familiar with agile methods are familiar with the idea of the spike. A spike is a time-boxed task that concentrates on clarifying the unknowns in your project. Usually these are technological (&#8220;can this be done with this technology?&#8221;) but they are also sometimes in the area of the business domain (&#8220;is this a [...]]]></description>
			<content:encoded><![CDATA[<p>Most developers familiar with agile methods are familiar with the idea of the <em>spike</em>. A spike is a time-boxed task that concentrates on clarifying the unknowns in your project. Usually these are technological (&#8220;can this be done with this technology?&#8221;) but they are also sometimes in the area of the business domain (&#8220;is this a good idea?&#8221;) too. One key idea is that the at the end of the spike, it is thrown away. It&#8217;s not supposed to be used as production code, it&#8217;s just supposed to answer some questions about the project, to validate or invalidate particular approaches to a problem, to provide further clarity around unknowns, to explore risk, to help with estimation, etc. I think this can be a useful general idea when dealing with technology, even in a &#8220;production&#8221; context.</p>
<p>Recently I was learning <a href="http://www.antlr.org">ANTLR</a>, trying to decide whether this was a right technology to pursue a particular project which involved parsing a preexisting message format. After a week of a spike, we decided that it was worth pursuing and started on earnest on the grammar for our project. However a week into this process, I had an epiphany &#8230; I was doing some things wrong with the ANTLR grammar which were now slowing progress in adding the new characteristics it needed to be complete. Many developers know this feeling; the features of my grammar that I had built over the first week were naive and now hampering it from expanding into the new requirements. I took it on myself to kill the entire grammar and start again. It took less than a day and half to replicate that week&#8217;s worth of work (i.e. pass the test suite which had built up around it).  I&#8217;ve done this before; scrap the first attempt at building a domain and try again. Here my domain was the same (it was after all defined in both a standards specification and in the many hundreds of thousands of sample messages we captured from an existing system), but its implementation needed refinement.</p>
<p>So I think that the rule about throwing away spikes can in fact be made a general axiom of programming:</p>
<blockquote><p>When you are learning a new technology, make sure you  throw away the first thing you build that works &#8211; to avoid accumulating  your mistakes.</p></blockquote>
<p>Thanks to <a href="http://www.twasink.net/">Robert</a> for the important qualifier &#8220;that works&#8221;. <img src='http://www.crazymcphee.net/x/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>N.B. my views about <a title="The rewrite will be ready shortly" href="http://www.crazymcphee.net/x/2009/02/01/the-rewrite-will-be-ready-shortly/">system  rewrites</a> have not changed regardless.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.crazymcphee.net/x/2010/05/30/throw-it-away-and-write-another-one/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Systems versus Individuals and technical debt</title>
		<link>http://www.crazymcphee.net/x/2009/09/05/systems-versus-individuals-and-technical-debt/</link>
		<comments>http://www.crazymcphee.net/x/2009/09/05/systems-versus-individuals-and-technical-debt/#comments</comments>
		<pubDate>Fri, 04 Sep 2009 23:38:48 +0000</pubDate>
		<dc:creator>Scot Mcphee</dc:creator>
				<category><![CDATA[professional practice]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[emergent design]]></category>
		<category><![CDATA[methodology]]></category>
		<category><![CDATA[profession]]></category>
		<category><![CDATA[refactor]]></category>
		<category><![CDATA[technical debt]]></category>

		<guid isPermaLink="false">http://www.crazymcphee.net/x/?p=468</guid>
		<description><![CDATA[I kind of disagree with this picture by Josh Susser regarding the &#8220;circle of death&#8221; in terms of code quality and late night effort. It is right enough as far as it goes but it doesn&#8217;t go far enough. First up, the easy way out &#8211; take a day off, go for a walk in [...]]]></description>
			<content:encoded><![CDATA[<p>I kind of disagree with <a href="http://blog.hasmanythrough.com/2009/9/3/circle-of-death">this picture</a> by Josh Susser regarding the &#8220;circle of death&#8221; in terms of code quality and late night effort. It is right enough as far as it goes but it doesn&#8217;t go far enough.</p>
<p>First up, the easy way out &#8211; take a day off, go for a walk in the park, have a nice dinner, get a good nights sleep. You should always work to &#8220;sustainable progress&#8221; and yes this means every hour you work over 40 hours a week means your quality is steadily decreasing until some point where every extra hour you put will take two to fix it later (in other words, negative impact). Even just pair programming will help prevent this in the first place as long at least one of you isn&#8217;t operating on half the sleep they need. But ultimately, all of this just blames the individual, when really poor code quality and technical debt are much more a function of the management system, methodology, total sum of the choices by every on the team, etc. (For a start, why are you up late in the first place? Was that your choice, or an outside imposed deadline?).</p>
<p>As James Adam and &#8220;iSteve&#8221; point out in the comments &#8211; technical debt is different from just &#8220;buggy software&#8221; and in my experience it&#8217;s usually function of management or other types of systemic choices (and &#8220;systemic&#8221; includes you, the programmer as well everyone else). What it really does is trade <em>easy change now</em> for <em>even harder change later</em>. It wants that sweet sweet sugar hit straight away but forgets about the &#8220;sugar coma&#8221; that comes a few minutes afterwards. It defers &#8220;paying the piper&#8221; until tomorrow for that lovely tune today. James Adam rightly says in his comment this <em>can be a valid choice</em>, but all of the team have to be fully aware of the <em>consequences</em> of that choice. One of which is typically that the longer  you defer the payment, the more debt you&#8217;ll accumulate, until all you are doing is paying off the interest and not getting to the principal.</p>
<p>As &#8220;iSteve&#8221; says, management (and maybe &#8220;management&#8221; might mean just you telling yourself this in your head) always promises to &#8220;fix it later&#8221; and never does allow that. &#8220;Just make the hack&#8221; and gloss over the problem is a mantra that we&#8217;ve all heard before. Where it gets painful is where every change is now taking twice as long as it should because of the accumulation of hacks. Every single one one of us has been there before, and are probably in various levels of it right now.</p>
<p>In my view this is the much more insidious circumstance because it is <em>systemic</em>.  After all the solution to a bad day&#8217;s work because I was too tired to think properly is to simply get a good night&#8217;s sleep, roll back yesterday&#8217;s coding, and do it again today. All I&#8217;ve done is lost a day&#8217;s work.  However, an organisation is likely to have accumulated months if not years of organisational cruft that makes changing their context that much harder than just rolling back yesterday&#8217;s poor code and trying again &#8211; it requires commitment to change from everyone who counts in the first instance.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.crazymcphee.net/x/2009/09/05/systems-versus-individuals-and-technical-debt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>To do redux</title>
		<link>http://www.crazymcphee.net/x/2009/06/07/to-do-redux/</link>
		<comments>http://www.crazymcphee.net/x/2009/06/07/to-do-redux/#comments</comments>
		<pubDate>Sat, 06 Jun 2009 22:50:45 +0000</pubDate>
		<dc:creator>Scot Mcphee</dc:creator>
				<category><![CDATA[professional practice]]></category>
		<category><![CDATA[rants]]></category>
		<category><![CDATA[agile]]></category>
		<category><![CDATA[methodology]]></category>
		<category><![CDATA[profession]]></category>
		<category><![CDATA[refactor]]></category>
		<category><![CDATA[xp]]></category>

		<guid isPermaLink="false">http://www.crazymcphee.net/x/?p=393</guid>
		<description><![CDATA[I just want to answer the anonymous &#8220;process nazis&#8221; trackback on yesterday&#8217;s &#8216;//TODO&#8217; Considered Harmful post, because that blog desn&#8217;t allow comments without a login. Quite apart from issues with Godwin&#8217;s Law (and that the writer has enumerated a bunch of rules that get &#8220;violated&#8221; then accuses other people of being process nazis), the post [...]]]></description>
			<content:encoded><![CDATA[<p>I just want to answer the anonymous &#8220;<a href="http://chaosinmotion.com/blog/?p=279">process nazis</a>&#8221; trackback on yesterday&#8217;s <a href="http://www.crazymcphee.net/x/2009/06/06/todo-considered-harmful/">&#8216;//TODO&#8217; Considered Harmful</a> post, because that blog desn&#8217;t allow comments without a login. Quite apart from issues with Godwin&#8217;s Law (and that the writer has enumerated a bunch of rules that get &#8220;violated&#8221; then accuses <em>other</em> people of being process nazis), the post severely misattributes both my post, and also, I think, misunderstands what agile methodologies are all about.</p>
<p>First, I no where made any &#8220;assertion that if you are putting ‘//TODO’ markers in your code, you’re somehow not properly following the Scrum process&#8221; &#8211; I said if you find yourself using &#8216;//TODO&#8217; markers in your code you are being prevented from getting to done-done and that you should &#8220;<em>Identify the problem, propose a counter-measure and fix the process</em>&#8220;. I can&#8217;t emphasise that enough. &#8220;Fix the process&#8221; does not mean &#8220;follow scrum&#8221; but rather to use your team&#8217;s collective brain to work out what stops you from fixing the code then and there and propose a solution to the problem.</p>
<p>I think &#8216;//TODO&#8217; should either be in the current story (I will concede that you might want to use a &#8216;//TODO&#8217; to remind yourself about tasks in your current story, i.e. &#8220;come back here tomorrow when I add the validation&#8221;) or in the &#8220;backlog&#8221;. I put &#8220;backlog&#8221; in quotes there to point out I mean &#8220;backlog&#8221; in the broadest sense, if you using Scrum or XP that&#8217;s actually where the work-to-be-done is physically kept, but if you have some other process then your &#8220;backlog&#8221; is kept somewhere else, and what is preventing you from adding to it?</p>
<p>I will ask a question of the anonymous poster &#8211; at what point exactly  is a &#8216;//TODO&#8217; comment left decaying in the codebase without a story for days or weeks <em>a good idea</em>? Or is it that you just do not want to make what it is being done in the code base <em>transparent</em> to those who are paying your bills?</p>
<p>I will contend; &#8216;//TODO&#8217; never gets done because the product owners never see them. They act as an opaque barrier to open communication. If you find a &#8216;//TODO&#8217;, lets say a big major refactoring will be needed to support a story you already see in the backlog, what&#8217;s the problem with having an open and honest communication with the <em>team</em> about the story&#8217;s estimate? If it&#8217;s a future story, i.e. feature related, it should be in the &#8220;backlog&#8221;; if it is code or design related which impacts you now, either it should be done then and there (<a href="http://www.extremeprogramming.org/rules/refactor.html">refactor mercilessly</a>) or it&#8217;s a bug which you either fix or raise a bug report for, and if it&#8217;s just some nebulous &#8220;improvement&#8221; either do it now or <a href="http://c2.com/xp/YouArentGonnaNeedIt.html">YAGNI</a>. If you&#8217;ve got great tooling like Mylyn for Eclipse you can drop a &#8220;task&#8221; at the code point and move on. The point there is the &#8220;TODO&#8221; isn&#8217;t obscured away in the code but rather <em>visible to all</em> because the &#8216;//TODO&#8217; is now either in your Wiki, your task-tracking tooling via it&#8217;s Mylyn integration, or is included as part of a story card on the story board.</p>
<p>If you can&#8217;t refactor mercilessly &#8211; what the post is <em>really</em> about &#8211; all the usual excuses apply, i.e. &#8220;we&#8217;re not confident about the code base not breaking in unknown ways&#8221; (i.e. no tests), &#8220;it has to be done by tomorrow,&#8221; <em>et cetera</em>, and all of these are <em>symptoms of dysfunction</em> in your organisation.</p>
<p>People love their little comfort zones and they don&#8217;t like being pushed out of them, that&#8217;s for sure, programmers included (yeah, and that&#8217;s a me too). <em>Habit</em> is not an excuse for avoiding improvement.</p>
<p>Here&#8217;s a great imaginary conversation from the C2 wiki entry about <a href="http://c2.com/xp/YouArentGonnaNeedIt.html">YAGNI</a> that I think applies here:</p>
<blockquote><p>&#8220;But Ron, I know how to do it right now, and later I might not.&#8221; </p>
<p>&#8220;So, Sam, you&#8217;re telling me that this class you&#8217;re writing is so complex that even <strong>you</strong> won&#8217;t be able to maintain it?&#8221;</p>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.crazymcphee.net/x/2009/06/07/to-do-redux/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>&#8216;//TODO&#8217; considered harmful</title>
		<link>http://www.crazymcphee.net/x/2009/06/06/todo-considered-harmful/</link>
		<comments>http://www.crazymcphee.net/x/2009/06/06/todo-considered-harmful/#comments</comments>
		<pubDate>Fri, 05 Jun 2009 14:14:12 +0000</pubDate>
		<dc:creator>Scot Mcphee</dc:creator>
				<category><![CDATA[professional practice]]></category>
		<category><![CDATA[tools and techniques]]></category>
		<category><![CDATA[agile]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[methodology]]></category>
		<category><![CDATA[profession]]></category>
		<category><![CDATA[refactor]]></category>

		<guid isPermaLink="false">http://www.crazymcphee.net/x/?p=386</guid>
		<description><![CDATA[Yesterday I said that developers should start being a little more militant about the craftsmanship of their code, i.e. pushing back on broken methodology that demands poorly-built code  be released into the wild. This sort of code is always inherently fragile and will break your software if it has not already. Today I just want [...]]]></description>
			<content:encoded><![CDATA[<p><a title="Just Say No (to broken processes)" href="http://www.crazymcphee.net/x/2009/06/05/just-say-no-to-broken-processes/">Yesterday I said that developers should start being a little more militant about the craftsmanship of their code</a>, i.e. pushing back on broken methodology that demands poorly-built code  be released into the wild. This sort of code is always inherently fragile and will break your software if it has not already.</p>
<p>Today I just want to meditate on a code artifact that often manifests itself in such environments. I speak of the comment //TODO seen frequently in such code. The idea that future &#8220;refactoring&#8221; goes on the &#8220;todo&#8221; list in such an environment is completely broken. An environment that allows that to happen means it will never get done. Do it now, or don&#8217;t do it. <a title="C2 Wiki - ToDo comments considered harmful" href="http://c2.com/cgi/wiki?TodoCommentsConsideredHarmful" target="_self">TODO is considered harmful</a>.</p>
<p>I have come around to the view that &#8216;//TODO&#8217; comments should make a build fail. Either:</p>
<ol>
<li>It is a future story yet to be implemented and placed into the backlog,</li>
<li>It is work in progress (and by definition doesn&#8217;t need a TODO because everything still needs to be &#8216;done&#8217;), or,</li>
<li>It is done, as in DONE-done, and therefore the story is complete and there&#8217;s nothing left &#8220;TO DO&#8221;.</li>
</ol>
<p>In other words, &#8220;//TODO&#8221; is a indicator of a process that&#8217;s not letting developers get to &#8220;done&#8221;. Identify the problem, propose a counter-measure and fix the process that stopping you from getting to completion.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.crazymcphee.net/x/2009/06/06/todo-considered-harmful/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>Just Say No (to broken processes)</title>
		<link>http://www.crazymcphee.net/x/2009/06/05/just-say-no-to-broken-processes/</link>
		<comments>http://www.crazymcphee.net/x/2009/06/05/just-say-no-to-broken-processes/#comments</comments>
		<pubDate>Thu, 04 Jun 2009 23:23:27 +0000</pubDate>
		<dc:creator>Scot Mcphee</dc:creator>
				<category><![CDATA[professional practice]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[emergent design]]></category>
		<category><![CDATA[methodology]]></category>
		<category><![CDATA[refactor]]></category>

		<guid isPermaLink="false">http://www.crazymcphee.net/x/?p=384</guid>
		<description><![CDATA[Broken development processes lead to broken code. When you find badly formed code, and especially if you didn&#8217;t  write it just then in order to make the test pass just a minute ago, and super-especially is the code is already in production, you not only need to rectify the code, you need to rectify the [...]]]></description>
			<content:encoded><![CDATA[<p>Broken development processes lead to broken code. When you find badly formed code, and <em>especially</em> if you didn&#8217;t  write it just then in order to make the test pass just a minute ago, and <em>super-especially</em> is the code is already in production, you not only need to rectify the <em>code</em>, you need to rectify the <em>process</em> that lead to the broken code. Well, to be accurate, you need to start engaging in some root-cause-analysis on how this badly formed code came to be included in the production system.</p>
<p>On a technical mailing list I&#8217;m on, a developer asked for help in regard to a class he had to modify. There&#8217;s no need for the full gory detail here; suffice to say it&#8217;s main feature was that it had a very long if-then-else method that had nearly 20 steps testing multiple boolean statuses strung out after each other. The question was very simply; &#8220;how to refactor this?&#8221;. The suggestions were all good; ranging from using polymorphism to implementing a rules engine.</p>
<p>It&#8217;s not the solutions, or even the code that I want to discuss. Near the end of the thread, the original poster came back and said he&#8217;d discovered that (to paraphrase) &#8216;the feature change needs to go to the QA process today&#8217; and that the refactoring couldn&#8217;t be done: the two-line hack would have to suffice.</p>
<p>I feel for the poor bugger, I really do, I&#8217;ve been in that situation myself. Maybe it&#8217;s just my bombastic, iconoclastic nature that makes me push back at these situations and tell people what fools they are for not valuing the <em>craftsmanship</em> of the very craftsmen they&#8217;ve hired specifically to build their software solutions. We need to start to insist that craftsmanship is valued and not just dismissed with an airy wave of the hand by management anymore. I&#8217;m fully aware this frequently makes me unpopular amongst those who don&#8217;t like to told the hard, brutal, truth. But I&#8217;ve given up caring. The truth it is.</p>
<p>In this spirit, I&#8217;m going to put on my &#8220;I&#8217;m as mad as hell and I&#8217;m not gonna take this anymore&#8221; hat and say the following. The reason that class in that state is because &#8220;changes to this feature are going to need to be in a build for QA today&#8221;. What needs to be done about these situations?</p>
<p>Just Say No.</p>
<p>Developers &#8211; those aspiring to be craftsmen anyway, need to be able to say it just is not possible for this feature to be changed today. Tell the management they have maxed out the credit card and the bailiffs are banging at the door and taking the silverware away as payment.</p>
<p>For a start, who decided this feature had to be in the QA build at some arbitrary cut-off date anyway? Someone who had never seen that class, that&#8217;s who. That &#8220;chicken&#8221; committed developer &#8211; the &#8220;pig&#8221; &#8211; to deliver the feature by some arbitrary cut off date and didn&#8217;t know the details. This is estimation by <em>fiat</em>. In any half-way decent process that respects it&#8217;s workers as people and not jut bit-flippers, no-one has the right to do this; it&#8217;s massively broken process. Chickens are not allowed to decide on estimates: only pigs are. The only way these things change if someone stands up and says &#8220;NO&#8221; to such broken process.</p>
<p>I don&#8217;t mean to say the developers can just go off with the fairies and gold-plate every piece of code they touch. But it has to be at least <em>well-made</em>. Obviously this particular process isn&#8217;t an agile environment &#8211; as it includes a &#8220;QA&#8221; stage with arbitrary cut off date at which point hte code &#8220;gets thrown over the wall&#8221;. And the company has management (I assume it&#8217;s management) running around and setting arbitrary delivery dates for unknown work.</p>
<p>Seriously, process improvement has to start somewhere. Be the change you seek. Stop tolerating poor code. If the process you work in demands you to tolerate it, change the process as best you can.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.crazymcphee.net/x/2009/06/05/just-say-no-to-broken-processes/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>I&#8217;m not making this mess anymore!</title>
		<link>http://www.crazymcphee.net/x/2009/03/17/im-not-making-this-mess-anymore/</link>
		<comments>http://www.crazymcphee.net/x/2009/03/17/im-not-making-this-mess-anymore/#comments</comments>
		<pubDate>Tue, 17 Mar 2009 12:14:48 +0000</pubDate>
		<dc:creator>Scot Mcphee</dc:creator>
				<category><![CDATA[professional practice]]></category>
		<category><![CDATA[technical]]></category>
		<category><![CDATA[agile]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[craftsmanship]]></category>
		<category><![CDATA[emergent design]]></category>
		<category><![CDATA[profession]]></category>
		<category><![CDATA[refactor]]></category>
		<category><![CDATA[scrum]]></category>
		<category><![CDATA[test driven design]]></category>
		<category><![CDATA[xp]]></category>

		<guid isPermaLink="false">http://www.crazymcphee.net/x/?p=236</guid>
		<description><![CDATA[XP: After 10 years why are we still talking about it? By Robert C. Martin. Uncle Bob argues passionately, and correctly, for the principles of software craftsmanship. Link: http://www.viddler.com/explore/sergiopereira/videos/7/.]]></description>
			<content:encoded><![CDATA[<p>XP: After 10 years why are we still talking about it? By Robert C. Martin. Uncle Bob argues passionately, and correctly, for the principles of software craftsmanship.</p>
<p><object width="437" height="370" data="http://www.viddler.com/player/ef4eb06a/" type="application/x-shockwave-flash"><param name="id" value="viddler_ef4eb06a" /><param name="wmode" value="transparent" /><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="true" /><param name="src" value="http://www.viddler.com/player/ef4eb06a/" /><param name="name" value="viddler_ef4eb06a" /><param name="allowfullscreen" value="true" /></object></p>
<p>Link: <a href="http://www.viddler.com/explore/sergiopereira/videos/7/"> http://www.viddler.com/explore/sergiopereira/videos/7/</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.crazymcphee.net/x/2009/03/17/im-not-making-this-mess-anymore/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The rewrite will be ready shortly</title>
		<link>http://www.crazymcphee.net/x/2009/02/01/the-rewrite-will-be-ready-shortly/</link>
		<comments>http://www.crazymcphee.net/x/2009/02/01/the-rewrite-will-be-ready-shortly/#comments</comments>
		<pubDate>Sun, 01 Feb 2009 00:58:09 +0000</pubDate>
		<dc:creator>Scot Mcphee</dc:creator>
				<category><![CDATA[architecture]]></category>
		<category><![CDATA[business]]></category>
		<category><![CDATA[technical]]></category>
		<category><![CDATA[methodology]]></category>
		<category><![CDATA[poorly attempted humour]]></category>
		<category><![CDATA[refactor]]></category>
		<category><![CDATA[rewrite]]></category>

		<guid isPermaLink="false">http://www.crazymcphee.net/x/?p=121</guid>
		<description><![CDATA[You might have seen the following cartoon before: It&#8217;s from a site called The Project Cartoon. What I didn&#8217;t know was the site allows you to use the little cartoons to make your own version. You can caption and re-order the panels. For your amusement, and perhaps your edification, I present &#8220;The Rewrite Will Be [...]]]></description>
			<content:encoded><![CDATA[<p>You might have seen the following cartoon before:</p>
<div id="attachment_120" class="wp-caption alignnone" style="width: 310px"><a href="http://www.projectcartoon.com/cartoon/3"><img class="size-medium wp-image-120" title="How the customer explained it ... what the customer needed" src="http://www.crazymcphee.net/x/wp-content/uploads/2009/02/how-the-customer-explaned-it-300x225.jpg" alt="The Project Cartoon - how the customer explained it, what we built them &amp; what the customer actually needed" width="300" height="225" /></a><p class="wp-caption-text">The Project Cartoon - how the customer explained it, what we built them &amp; what the customer actually needed</p></div>
<p>It&#8217;s from a site called <a title="The Project Cartoon" href="http://www.projectcartoon.com/" target="_blank">The Project Cartoon</a>. What I didn&#8217;t know was the site allows you to use the little cartoons to make your own version. You can caption and re-order the panels.  For your amusement, and perhaps your edification, I present &#8220;The Rewrite Will Be Ready Shortly&#8221;:</p>
<div id="attachment_125" class="wp-caption alignnone" style="width: 490px"><a href="http://www.projectcartoon.com/cartoon/42216"><img class="size-full wp-image-125" title="The Rewrite Will Be Ready Shortly" src="http://www.crazymcphee.net/x/wp-content/uploads/2009/02/therewrite600.jpg" alt="The existing software is ugly and poorly written. We will have to rewrite it if you want any new features." width="480" height="339" /></a><p class="wp-caption-text">The existing software is ugly and poorly written. We will have to rewrite it if you want any new features.</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.crazymcphee.net/x/2009/02/01/the-rewrite-will-be-ready-shortly/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Code re-writes and U.S. health care reform</title>
		<link>http://www.crazymcphee.net/x/2009/01/20/code-re-writes-and-us-health-care-reform/</link>
		<comments>http://www.crazymcphee.net/x/2009/01/20/code-re-writes-and-us-health-care-reform/#comments</comments>
		<pubDate>Tue, 20 Jan 2009 08:16:53 +0000</pubDate>
		<dc:creator>Scot Mcphee</dc:creator>
				<category><![CDATA[architecture]]></category>
		<category><![CDATA[professional practice]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[emergent design]]></category>
		<category><![CDATA[methodology]]></category>
		<category><![CDATA[refactor]]></category>
		<category><![CDATA[rewrite]]></category>

		<guid isPermaLink="false">http://www.crazymcphee.net/x/?p=70</guid>
		<description><![CDATA[This post is not about health-care, per se. This is about &#8220;re-writes&#8221; or &#8220;total reforms&#8221; of systems. An argument Atul Gawande makes in New Yorker magazine about health-care reform: [Certain reformists say] The country has this one chance, the idealist maintains, to sweep away our inhumane, wasteful patchwork system and replace it with something new [...]]]></description>
			<content:encoded><![CDATA[<p>This post is not about health-care, per se. This is about &#8220;re-writes&#8221; or &#8220;total reforms&#8221; of systems. <a href="http://www.newyorker.com/reporting/2009/01/26/090126fa_fact_gawande?currentPage=all">An argument Atul Gawande makes in New Yorker magazine about health-care reform</a>:</p>
<blockquote><p>[Certain reformists say] The country has this one chance, the idealist maintains, to sweep away our inhumane, wasteful patchwork system and replace it with something new and more rational. So we should prepare for a bold overhaul, just as every other Western democracy has. True reform requires transformation at a stroke. But is this really the way it has occurred in other countries? The answer is no. And the reality of how health reform has come about elsewhere is both surprising and instructive.</p></blockquote>
<p>He goes at lengths to explain how the health care that the rest of the developed world (e.g. Australia) has found itself with, are the results of ad-hoc changes to existing systems, not large-scale rewrites. As a result, every country has a &#8220;path-dependent&#8221; health care system. For example, Britain&#8217;s NHS evolved in 1945 from wartime requirements and infrastructure. After the way, France&#8217;s infrastructure was largely destroyed, so they used (that is, modified and extended) an existing system of union organised health care insurance paid for through payroll taxes. And so on. Everyone&#8217;s system is different because their initial conditions where different, and solutions have to respect what&#8217;s there, and not just blithely sweep it all aside.</p>
<p>This possibly could give us a <em>general</em> principle with regards to all types of reform -<em> you have to work with what you&#8217;ve got</em>. That includes software.</p>
<p>We&#8217;ve <a href="http://www.oreillynet.com/onlamp/blog/2007/08/informal_survey_do_rewrites_re.html" target="_blank">known</a> for <a title="Joel On Software - Things Not To Do" href="http://www.joelonsoftware.com/articles/fog0000000069.html" target="_blank">some time</a> that the <a title="The Big Rewrite" href="http://chadfowler.com/2006/12/27/the-big-rewrite" target="_blank">big rewrite</a><a href="http://www.ronkes.nl/blog/?2005-04-15-neverrewritecode" target="_blank"> nearly always</a> <a href="http://www.oreillynet.com/ruby/blog/2007/09/7_reasons_i_switched_back_to_p_1.html" target="_blank">ends</a> in <a href="http://www.jwz.org/gruntle/nomo.html" target="_blank">failure</a> (although <a href="http://codehappy.wordpress.com/tag/rewrites-development-code-smells/" target="_blank">not everyone</a> <a href="http://my.opera.com/Vorlath/blog/2007/09/25/code-rewrite-yes" target="_blank">agrees</a>). Especially when the specification for the new system is &#8220;make it do what the old system does&#8221;. Why are you re-writing it then?! (<a title="Software as the The Spec" href="http://chadfowler.com/index.cgi/Computing/Programming/TheBigRewrite/TheSpec.rdoc,v" target="_blank">Chad Fowler has an excellent article about this</a>).</p>
<p>It&#8217;s an excellent general principle that software systems should to evolve  incrementally over time. Has anyone else worked in an environment where they&#8217;ve spent 12, 18, 24 months squirrelled away somewhere vigorously rewriting an entire system while the existing system is still being maintained and improved? Not so long ago I worked on a system where we spent 4 months re-writing just a small section of a piece of software &#8211; delivered in two steps &#8211; and it was bad enough as it was. But a <em>year</em>? It just has to be disastrous.</p>
<p>What&#8217;s important is your initial set of conditions, which shape the scope of what is actually possible to do &#8211; and importantly, how you&#8217;d go about doing it. Your future system is &#8220;path dependent&#8221; on the existing one, and that was dependant on what was there before.  Software developers frequently chafe at these limits, and instead form a desire to just chuck it out and start over. But you are dooming yourself to failure if you do that.</p>
<p>Part of our professional practices  should be the delivery of <a title="Emergent Design" href="http://www.crazymcphee.net/x/2009/01/13/emergent-design/" target="_self">incremental design to systems</a>. Instead of that 4 month re-write of a small section of functionality could we have delivered it in even smaller chunks? My feeling is <em>quite probably, yes</em> &#8211; and it would have been a lot less stressful at the time too. Always work with what you&#8217;ve got, and change -and <em>improve</em> &#8211; it one small piece at a time.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.crazymcphee.net/x/2009/01/20/code-re-writes-and-us-health-care-reform/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

