<?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>Pramatr Blog &#187; Structure</title>
	<atom:link href="http://www.pramatr.com/blog/tag/structure/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.pramatr.com/blog</link>
	<description>A collection of articles from pramatr.com on technology, security, software and anything we find interesting</description>
	<lastBuildDate>Mon, 29 Mar 2010 19:48:11 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Documentation: Update It Or Lose It</title>
		<link>http://www.pramatr.com/blog/2009/02/17/documentation-update-it-or-lose-it/</link>
		<comments>http://www.pramatr.com/blog/2009/02/17/documentation-update-it-or-lose-it/#comments</comments>
		<pubDate>Tue, 17 Feb 2009 06:43:31 +0000</pubDate>
		<dc:creator>pramatr</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Opinion]]></category>
		<category><![CDATA[Refactoring]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Code Review]]></category>
		<category><![CDATA[Communication]]></category>
		<category><![CDATA[Discipline]]></category>
		<category><![CDATA[Improvement]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Smells]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Structure]]></category>

		<guid isPermaLink="false">http://pramatr.com/?p=17</guid>
		<description><![CDATA[Over time I&#8217;m frequently restructuring and refactoring the code I work on to improve the design and simplify many of the balls of mud I find along the way. If I break some of that code my unit tests shout at me and if they don&#8217;t my continuous integration environment shouts at me when I&#8217;ve [...]]]></description>
			<content:encoded><![CDATA[<p>Over time I&#8217;m frequently <a href="http://pramatr.com/2008/09/26/yes-you-are-making-changes-but-that-doesnt-make-it-refactoring/">restructuring and refactoring</a> the code I work on to improve the design and simplify many of the <a href="http://www.laputan.org/mud/mud.html#BigBallOfMud">balls of mud</a> I find along the way. If I break some of that code my unit tests shout at me and if they don&#8217;t my <a>continuous integration</a> environment shouts at me when I&#8217;ve <a>broken</a> one of the integration tests. One area of the code that doesn&#8217;t receive the same attention however is the documentation.</p>
<p>I love a well documented API as much as the next developer. I also am fighting a constant battle to improve my JavaDoc <a href="http://java.sun.com/j2se/javadoc/writingdoccomments/">skills</a>, trying to write to the same quality that I see in many other projects. But is excellent documentation really enough? It can&#8217;t just be excellent when it&#8217;s written it needs to be constantly maintained to this same level over time.</p>
<p>It&#8217;s a pretty common occurrence that I can look at a section of code and find documentation that has nothing to do with the method it belongs to. The <a href="http://www.c2.com/cgi/wiki/wiki?IntentionRevealingNames">intention revealing name</a> sounds nothing like the documentation which describes what it&#8217;s supposed to be doing. Somewhere in the mists of time, the intention of the method and the documentation parted company; it is documentation no more it is ex-documentation. The problem here however is that there&#8217;s nothing to catch this issue. If an extra argument is added, Eclipse might display a warning telling me it&#8217;s missing from the documentation, but the actual context of the documentation can be completely wrong and I am none the wiser.</p>
<p>Although this incorrect documentation may seem fairly harmless to some, the reason it was supposed to be there in the first place is to the give the user of the API information on the method contract and the expected outcomes. If this information is completely wrong however it introduces confusion and also potential misuse of the API. After much wasted time and several grey hairs later I recently filed a couple of JIRA reports about popular open source frameworks which did exactly this. After my code just didn&#8217;t work and the unit tests failed, it took me a number of minutes to realise that the JavaDoc description of expected events just didn&#8217;t reflect what was actually going on in the code.</p>
<p>One approach to solving this problem is to include the documentation in the <a href="http://pramatr.com/2009/01/27/frequent-code-reviews-the-key-to-success/">frequent code reviews</a>. Code that doesn&#8217;t have documentation or has incorrect documentation can&#8217;t be considered complete, thus doesn&#8217;t pass the review. Developers need to make sure however, that they treat the documentation with the same respect that they give to their code and their tests. When dealing with documentation I&#8217;d much sooner see a method with no documentation than something that is completely wrong. I do want a good level of documentation in the code I work on but there is a very simple rule; update it or lose it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pramatr.com/blog/2009/02/17/documentation-update-it-or-lose-it/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Frequent Code Reviews The Key To Success?</title>
		<link>http://www.pramatr.com/blog/2009/01/27/frequent-code-reviews-the-key-to-success/</link>
		<comments>http://www.pramatr.com/blog/2009/01/27/frequent-code-reviews-the-key-to-success/#comments</comments>
		<pubDate>Tue, 27 Jan 2009 06:35:24 +0000</pubDate>
		<dc:creator>pramatr</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Opinion]]></category>
		<category><![CDATA[Agile]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Code Review]]></category>
		<category><![CDATA[Communication]]></category>
		<category><![CDATA[Discipline]]></category>
		<category><![CDATA[Improvement]]></category>
		<category><![CDATA[Refactoring]]></category>
		<category><![CDATA[Smells]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Structure]]></category>
		<category><![CDATA[XP]]></category>

		<guid isPermaLink="false">http://pramatr.com/?p=218</guid>
		<description><![CDATA[Reviews are a widely used technique to analyse code for the presence of defects and potential improvements. Many successful teams continually review code to try to ensure a high level of quality and to constantly improve a developers ability to write good code. The arguments for and against code reviews have been made on many [...]]]></description>
			<content:encoded><![CDATA[<p>Reviews are a widely used technique to analyse code for the presence of defects and potential improvements. Many successful teams continually review code to try to ensure a high level of quality and to constantly improve a developers ability to write good code. The arguments for and against code reviews have been made on many <a href="http://www.codinghorror.com/blog/archives/000495.html">occasions</a>, but one common unknown factor for many teams is the frequency at which they should take place.</p>
<p><strong>Infrequent Reviews</strong></p>
<p>Many teams operate on a feature complete code review. At the end of the cycle of work, several developers sit down together with the author critiquing the delivered work. What often transpires here is that due to the huge mass of code delivered, the chances of a thorough review are rendered utterly <a href="http://www.osnews.com/story/19266/WTFs_m">impossible</a>. The plethora of code makes it difficult to find a starting point and thus potentially problematic code <a href="http://www.developerdotstar.com/community/node/5">isn&#8217;t</a> allocated the time it necessarily deserves. Any potential recommendations that come out of this kind of code may never see the light of day given the pressing work schedule (if the code was complete why are the changes necessary?). Most importantly for the team, reviewing code so infrequently can lead to demoralisation of its members.</p>
<p>Code reviews may pick apart the authors code; code that they have potentially sweat and cried over (ok maybe not) and worked hard to complete. Does it really make sense to save up all the potential criticism and deliver it in one skull crushing blow? Even if the criticism is perfectly valid, nobody likes to feel good about something only for it to be completely torn apart. Developers complain when customers only let them know what they actually want when they see what they don&#8217;t, is the same really acceptable for the code? If infrequent code reviews aren&#8217;t the answer, how often can code be successfully reviewed?</p>
<p><strong>Email Reviews</strong></p>
<p>Some teams never let the author of the code commit it to the repository. Instead, they email the code (typically in patch form) to the code owner or one of the principal reviewers. The idea behind this approach is the patches are always reviewed prior to them being committed, and the developers can work productively only focusing on the task in hand. This process has the ability to ensure that every change is scrutinised and verified to maintain the high quality standards that are set down. Having had to work with a system like this in the past, I can honestly say that it was fraught with problems and was one of the most frustrating I&#8217;ve ever worked with (I was one of the principal reviewers).</p>
<p>The person applying the patch quickly becomes a bottleneck in the process, how long can people really wait for the patch to be applied? What should the patch reviewer actually do with the patch, make the recommendations themselves or send an email back to the original author to apply the required changes. If multiple people are working on the code base, the chances of conflicts increase. If the patches are applied in the wrong order or peoples timing is just plain unlucky, the person applying the patch has a multitude of problems to deal with. The version control system is full of only one persons name, thus making it incredibly difficult to track down the original owner of the change. Lastly should the worst happen and the build fail&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.. guess who&#8217;s change it was that broke it?</p>
<p><strong>Frequent Reviews</strong></p>
<p>People like to know what and how they are doing with their work. If infrequent code reviews lead to a big bang delivery approach, then frequent code reviews take the inverse approach of small nudges in the right direction. By applying these frequent reviews, developers can deal with smaller suggestions and recommendations early in their development. Instead of developers feeling they have completed something only to be told it&#8217;s all wrong, they can be guided along the process to ensure they arrive at a right answer. The most difficult question here is; how frequent is frequent? This is a very developer specific metric.</p>
<p>Some developers require frequent attention and when I say frequent I mean every few hours (or more!). As developers become more experienced, this frequency typically reduces until the reviewed eventually becomes the reviewer. Depending on the type of project however, it&#8217;s still quite common for very experienced developers to like frequent code reviews. If frequent reviews become very frequent reviews, you might have unwittingly found yourself participating in quasi pair programming.</p>
<p><strong>Pair Programming</strong></p>
<p><a href="http://www.extremeprogramming.org/rules/pair.html">Pair programming</a> is not only a great way to develop but also to implicitly review code. A second developer sitting at the keyboard provides instantaneous reviewing of code. The second developer not only reviews the code, but also looks for potential problems and improvements to the evolving code. The second developer isn&#8217;t always necessarily the reviewer, and roles can switch between either developer during the exercise.</p>
<p>Having someone take over the keyboard encourages the development to be of higher quality and a second set of eyes prompts the coders to produce good code (obviously given a good pairing of developers). This instant review and feedback can actually reduce the number of bugs introduced into the system. As several developers produced the code, it also means that the team is never reliant on a single developer to address a given area of code. Pair programming is an excellent way of developing an reviewing code, but it&#8217;s not without it&#8217;s <a href="http://www.theregister.co.uk/2007/01/31/perils_pair_programming/">problems</a> with some people finding the feedback is just too often.</p>
<p><strong>Summary</strong></p>
<p>By reducing the time between code reviews, teams can provide better guidance about the eventual quality of code and prevent storing up potential problems. The less frequent the code reviews are the more problems (especially with less experienced staff) that occur. Developers want to feel like that are doing a good job and as such then need small bits of constructive criticism often instead of lots of criticism delivered all at once. Reviewing code is best addressed frequently, providing quicker feedback, and reducing the amount of rework involved. As a developers ability increases, these issues typically subside and they become active in reviewing other peoples code.</p>
<p>If infrequent code reviews are problematic, are frequent code reviews the key to success?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pramatr.com/blog/2009/01/27/frequent-code-reviews-the-key-to-success/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Tests Are Still Code</title>
		<link>http://www.pramatr.com/blog/2009/01/14/tests-are-still-code/</link>
		<comments>http://www.pramatr.com/blog/2009/01/14/tests-are-still-code/#comments</comments>
		<pubDate>Wed, 14 Jan 2009 16:33:09 +0000</pubDate>
		<dc:creator>pramatr</dc:creator>
				<category><![CDATA[Refactoring]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Code Review]]></category>
		<category><![CDATA[Coverage]]></category>
		<category><![CDATA[CPD]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Findbugs]]></category>
		<category><![CDATA[JUnit]]></category>
		<category><![CDATA[Opinion]]></category>
		<category><![CDATA[PMD]]></category>
		<category><![CDATA[Structure]]></category>

		<guid isPermaLink="false">http://pramatr.com/?p=15</guid>
		<description><![CDATA[Whilst performing code reviews recently, one of the major tasks was reviewing the tests accompanying the code. One of the most surprising discoveries, was the lack of attention paid to the tests and how regularly this was becoming an issue throughout the test code.
Test code is just as likely to contain bugs as the code [...]]]></description>
			<content:encoded><![CDATA[<p>Whilst performing code reviews recently, one of the major tasks was reviewing the tests accompanying the code. One of the most surprising discoveries, was the lack of attention paid to the tests and how regularly this was becoming an issue throughout the test code.</p>
<p>Test code is just as likely to contain bugs as the code it is supposed to be testing. After all, if the tests are just code, why wouldn&#8217;t it contain bugs. The possibilty of it containing bugs could actually be higher as it doesn&#8217;t have tests and in many teams isn&#8217;t treated with the same respect as the rest of the code. Tests must therefore be kept as <a href="http://en.wikipedia.org/wiki/KISS_principle">simple</a> and easy to understand as possible and employ the same <a href="http://pramatr.com/2008/08/17/structured-approaches-to-improving-code-quality/">tools and techniques</a> available when writing tests as are used in the rest of the code.</p>
<p><a href="http://pmd.sourceforge.net/">PMD</a> and <a href="http://findbugs.sourceforge.net/">FindBugs</a> are great tools to identify potential problems within code, but I have only ever seen one project that applies them to the test code. <a href="http://pmd.sourceforge.net/cpd.html">PMD/CPD</a> is a great tool to identify duplicate code blocks, but I have never seen a project apply it to test code. If duplicate code isn&#8217;t acceptable, why should it be tolerated in test code?</p>
<blockquote><pre><span style="font-size:small;">@<span style="color:#2040a0;">Test</span>
<strong>public</strong> <strong>void</strong> <span style="color:#2040a0;">updateFirstName</span><span style="color:#4444ff;"><strong>(</strong></span><span style="color:#4444ff;"><strong>)</strong></span> <span style="color:#4444ff;"><strong>{</strong></span>
    ...
    <span style="color:#2040a0;">User</span> <span style="color:#2040a0;">updated</span> <span style="color:#4444ff;">=</span> <span style="color:#2040a0;">getUserById</span><span style="color:#4444ff;"><strong>(</strong></span><span style="color:#2040a0;">expected</span>.<span style="color:#2040a0;">getId</span><span style="color:#4444ff;"><strong>(</strong></span><span style="color:#4444ff;"><strong>)</strong></span><span style="color:#4444ff;"><strong>)</strong></span><span style="color:#4444ff;">;</span>
    <span style="color:#2040a0;">assertNotNull</span><span style="color:#4444ff;"><strong>(</strong></span><span style="color:#2040a0;">updated</span><span style="color:#4444ff;"><strong>)</strong></span><span style="color:#4444ff;">;</span>
    <span style="color:#2040a0;">assertEquals</span><span style="color:#4444ff;"><strong>(</strong></span><span style="color:#2040a0;">expected</span>.<span style="color:#2040a0;">getFirstName</span><span style="color:#4444ff;"><strong>(</strong></span><span style="color:#4444ff;"><strong>)</strong></span>, <span style="color:#2040a0;">updated</span>.<span style="color:#2040a0;">getFirstName</span><span style="color:#4444ff;"><strong>(</strong></span><span style="color:#4444ff;"><strong>)</strong></span><span style="color:#4444ff;"><strong>)</strong></span><span style="color:#4444ff;">;</span>
    <span style="color:#2040a0;">assertEquals</span><span style="color:#4444ff;"><strong>(</strong></span><span style="color:#2040a0;">expected</span>.<span style="color:#2040a0;">getMiddleName</span><span style="color:#4444ff;"><strong>(</strong></span><span style="color:#4444ff;"><strong>)</strong></span>, <span style="color:#2040a0;">updated</span>.<span style="color:#2040a0;">getMiddleName</span><span style="color:#4444ff;"><strong>(</strong></span><span style="color:#4444ff;"><strong>)</strong></span><span style="color:#4444ff;"><strong>)</strong></span><span style="color:#4444ff;">;</span>
    <span style="color:#2040a0;">assertEquals</span><span style="color:#4444ff;"><strong>(</strong></span><span style="color:#2040a0;">expected</span>.<span style="color:#2040a0;">getLastName</span><span style="color:#4444ff;"><strong>(</strong></span><span style="color:#4444ff;"><strong>)</strong></span>, <span style="color:#2040a0;">updated</span>.<span style="color:#2040a0;">getLastName</span><span style="color:#4444ff;"><strong>(</strong></span><span style="color:#4444ff;"><strong>)</strong></span><span style="color:#4444ff;"><strong>)</strong></span><span style="color:#4444ff;">;</span>
<span style="color:#4444ff;"><strong>}</strong></span>

@<span style="color:#2040a0;">Test</span>
<strong>public</strong> <strong>void</strong> <span style="color:#2040a0;">updateMiddleName</span><span style="color:#4444ff;"><strong>(</strong></span><span style="color:#4444ff;"><strong>)</strong></span> <span style="color:#4444ff;"><strong>{</strong></span>
    ...
    <span style="color:#2040a0;">User</span> <span style="color:#2040a0;">updated</span> <span style="color:#4444ff;">=</span> <span style="color:#2040a0;">getUserById</span><span style="color:#4444ff;"><strong>(</strong></span><span style="color:#2040a0;">expected</span>.<span style="color:#2040a0;">getId</span><span style="color:#4444ff;"><strong>(</strong></span><span style="color:#4444ff;"><strong>)</strong></span><span style="color:#4444ff;"><strong>)</strong></span><span style="color:#4444ff;">;</span>
    <span style="color:#2040a0;">assertNotNull</span><span style="color:#4444ff;"><strong>(</strong></span><span style="color:#2040a0;">updated</span><span style="color:#4444ff;"><strong>)</strong></span><span style="color:#4444ff;">;</span>
    <span style="color:#2040a0;">assertEquals</span><span style="color:#4444ff;"><strong>(</strong></span><span style="color:#2040a0;">expected</span>.<span style="color:#2040a0;">getFirstName</span><span style="color:#4444ff;"><strong>(</strong></span><span style="color:#4444ff;"><strong>)</strong></span>, <span style="color:#2040a0;">updated</span>.<span style="color:#2040a0;">getFirstName</span><span style="color:#4444ff;"><strong>(</strong></span><span style="color:#4444ff;"><strong>)</strong></span><span style="color:#4444ff;"><strong>)</strong></span><span style="color:#4444ff;">;</span>
    <span style="color:#2040a0;">assertEquals</span><span style="color:#4444ff;"><strong>(</strong></span><span style="color:#2040a0;">expected</span>.<span style="color:#2040a0;">getMiddleName</span><span style="color:#4444ff;"><strong>(</strong></span><span style="color:#4444ff;"><strong>)</strong></span>, <span style="color:#2040a0;">updated</span>.<span style="color:#2040a0;">getMiddleName</span><span style="color:#4444ff;"><strong>(</strong></span><span style="color:#4444ff;"><strong>)</strong></span><span style="color:#4444ff;"><strong>)</strong></span><span style="color:#4444ff;">;</span>
    <span style="color:#2040a0;">assertEquals</span><span style="color:#4444ff;"><strong>(</strong></span><span style="color:#2040a0;">expected</span>.<span style="color:#2040a0;">getLastName</span><span style="color:#4444ff;"><strong>(</strong></span><span style="color:#4444ff;"><strong>)</strong></span>, <span style="color:#2040a0;">updated</span>.<span style="color:#2040a0;">getLastName</span><span style="color:#4444ff;"><strong>(</strong></span><span style="color:#4444ff;"><strong>)</strong></span><span style="color:#4444ff;"><strong>)</strong></span><span style="color:#4444ff;">;</span>
<span style="color:#4444ff;"><strong>}</strong></span></span></pre>
</blockquote>
<p>Over time, tests will inevitably suffer from the same problems as the rest of the code. Tests become bloated, complex, duplicated and hard to understand if they are not maintained and <a href="http://www.refactoring.com/">refactored</a> regularly just like the rest of the code. The potential problem with refactoring tests is that you are refactoring something which does not have tests to verify your <a href="http://pramatr.com/2008/09/26/yes-you-are-making-changes-but-that-doesnt-make-it-refactoring/">changes</a>, but testing tests is a controversial issue and can probably be better solved by conducting thorough code reviews.</p>
<p>Code reviews seem to be an underrated technique within test code. Having spoken to many other developers, the majority of them had never participated in any test code reviews, with only a small number having used this approach on several occasions. What makes this even stranger, is the fact that many of these developers do conduct code reviews on a semi-regular basis. This is somewhat anecdotal evidence, but it would be very interesting to see some real numbers on this subject. How many teams conduct thorough code reviews of tests and treat it with the same importance as the rest of the code?</p>
<p>Code without documentation is considered by many to not be code complete, but tests without documentation are a pretty common occurrence. Tests should be <a href="http://en.wikipedia.org/wiki/KISS_principle">simple</a>, which means documentation is not necessarily required, but does that same argument apply to the rest of the code? Tests can have <a href="http://xunitpatterns.com/Intent%20Revealing%20Name.html">intent revealing names</a> which are sufficient in describing the intended purpose of the test and projects like <a href="http://agiledox.sourceforge.net/">TestDox</a> can take this and turn it into readable documentation. Is this documentation sufficient, if the test fails, does it provide enough of a clue to what was actually being tested?</p>
<p>In the past I have found test documentation to be extremely useful when writting integration tests. This documentation described the tests not in developer terms, but instead in a use case form. By writing a simple parser, it was possible to generate documentation from the tests which would allow the QA team to understand which flows had been executed. More importantly, it also allow them to quickly understand what a individual test was doing when it failed. This documentation was written as an experiment, but it has proved extremely useful to both developers and QA when something goes wrong.</p>
<p>When writing tests, teams need to ensure they don&#8217;t neglect this code. Tests should be maintained, refactored, reviewed and measured to ensure the same <a href="http://pramatr.com/2008/08/17/structured-approaches-to-improving-code-quality/">quality</a> as they would in the rest of their code. Tests are still code.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pramatr.com/blog/2009/01/14/tests-are-still-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Yes You Are Making Changes, But That Doesn&#039;t Make It Refactoring!</title>
		<link>http://www.pramatr.com/blog/2008/09/26/yes-you-are-making-changes-but-that-doesnt-make-it-refactoring/</link>
		<comments>http://www.pramatr.com/blog/2008/09/26/yes-you-are-making-changes-but-that-doesnt-make-it-refactoring/#comments</comments>
		<pubDate>Fri, 26 Sep 2008 21:30:00 +0000</pubDate>
		<dc:creator>pramatr</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Opinion]]></category>
		<category><![CDATA[Refactoring]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Discipline]]></category>
		<category><![CDATA[Structure]]></category>

		<guid isPermaLink="false">http://pramatr.com/2007/09/26/yes-you-are-making-changes-but-that-doesnt-make-it-refactoring/</guid>
		<description><![CDATA[There are some words in software development that overtime lose all meaning. The more these words are used, and importantly, the more they are used out of context, the more the original meaning is lost. It becomes just one of those words that is fitted into a conversation without even thinking about it. One word [...]]]></description>
			<content:encoded><![CDATA[<p>There are some words in software development that overtime lose all meaning. The more these words are used, and importantly, the more they are used out of context, the more the original meaning is lost. It becomes just one of those words that is fitted into a conversation without even thinking about it. One word that often suffers from this problem is <strong><span class="blsp-spelling-error">refactoring</span></strong>.</p>
<p>The term <a href="http://www.refactoring.com/"><span class="blsp-spelling-error">Refactoring</span></a> is widely used throughout software development. <a href="http://en.wikipedia.org/wiki/Martin_Fowler">Martin Flower</a> is one of the primary <span class="blsp-spelling-error">documenters</span> of <span class="blsp-spelling-error">refactoring</span>, and popularised it in his seminal book, <a href="http://martinfowler.com/books.html"><span class="blsp-spelling-error">Refactoring</span>: Improving the Design of Existing Code</a>. Many people who use the word <span class="blsp-spelling-error">refactoring</span> however, have never heard of the book and more importantly don&#8217;t have a clear understanding of what <span class="blsp-spelling-error">refactoring</span> actually <a href="http://c2.com/cgi/wiki?WhatIsRefactoring">is</a>.</p>
<p><span class="blsp-spelling-error">Refactoring</span> is described as; a disciplined approach for modifying code without changing it&#8217;s externally observable behavior. This approach is focused around applying small changes to the code, each of which maintains the existing behaviour. By incrementally applying a number of <span class="blsp-spelling-error">refactorings</span>, the code can be modified in a measured and controlled manner. Extreme programming embraces this approach with a rule named <a href="http://www.extremeprogramming.org/rules/refactor.html"><span class="blsp-spelling-error">refactor</span> mercilessly</a>.</p>
<p><span id="more-87"></span>Alistair <span class="blsp-spelling-error">Cockburn</span> <a href="http://alistair.cockburn.us/index.php/ASD_book_extract:_%22Unknowable_and_incommunicable%22">wrote</a>; <em>&#8220;What we want to express sits in a crack between all the words we possess&#8221;</em>, it just so happens that for many people (including myself), one word that is readily available is <span class="blsp-spelling-error">refactoring</span>.</p>
<blockquote><p><strong>Team leader:</strong> So what are you currently working on?</p></blockquote>
<blockquote><p><em>Developer: I&#8217;m just <span class="blsp-spelling-error">refactoring</span> some code.</em></p></blockquote>
<blockquote><p><strong>Team leader:</strong> Are there any particular <span class="blsp-spelling-error">refactorings</span> that you&#8217;ve found useful?</p></blockquote>
<blockquote><p><em>Developer: Yes, I&#8217;m <span class="blsp-spelling-error">refactoring</span> the code.</em></p></blockquote>
<blockquote><p><strong>Team leader:</strong> No, I mean specific <span class="blsp-spelling-error">refactorings</span> e.g. rename method, extract method, etc&#8230;&#8230;</p></blockquote>
<blockquote><p><em>Developer: Yes I&#8217;ve been doing all that sort of thing.</em></p></blockquote>
<blockquote><p><strong>Team leader:</strong> Have you any idea when you might be finished?</p></blockquote>
<blockquote><p><em>Developer: I&#8217;m just trying to get the code compiling again, this might take a few hours.</em></p></blockquote>
<blockquote><p><strong>Team leader:</strong> <span class="blsp-spelling-error">Hmmmm</span> <span class="blsp-spelling-error">ok</span>, I&#8217;m presuming you&#8217;ve been reviewing, improving and running the unit tests frequently?</p></blockquote>
<blockquote><p><em>Developer: The code doesn&#8217;t have any unit tests, so there&#8217;s nothing to run.</em></p></blockquote>
<blockquote><p><strong>Team leader:</strong> Do you think it might be a <strong>good</strong> idea that you write some <strong>before</strong> you start <span class="blsp-spelling-error">refactoring</span>? How do you know that your code will work in the same way as it did?</p></blockquote>
<blockquote><p><em>Developer: <span class="blsp-spelling-error">Errrrr</span>&#8230;&#8230;</em></p></blockquote>
<p>If changes are informal or ad-<span class="blsp-spelling-error">hoc</span>, this <em>might</em> be acceptable, but this isn&#8217;t <span class="blsp-spelling-error">refactoring</span>. If changes will take days or weeks, or the code is simply being rewritten this isn&#8217;t <span class="blsp-spelling-error">refactoring</span>. If the code is just being hacked, this <strong>really</strong> isn&#8217;t <span class="blsp-spelling-error">refactoring</span>. Changes made in a controlled way are much more likely to be successful, but again this doesn&#8217;t necessarily mean <span class="blsp-spelling-error">refactoring</span>.</p>
<p><span class="blsp-spelling-error">Refactoring</span> is in many ways a victim of it&#8217;s own success. Many teams have found <span class="blsp-spelling-error">refactoring</span> to be a successful approach to making code changes in the past, leading to many people discussing all code changes as <span class="blsp-spelling-error">refactoring</span>. Sometimes this is simply due to a lack of understanding, other times it&#8217;s a lack of care and attention for the words being used. Sometimes however people use the word <span class="blsp-spelling-error">refactoring</span> to give the illusion of making disciplined changes, whilst reverting to plain old hacking.</p>
<p>There is a common perception amongst some teams, that every code change <strong>is</strong> <span class="blsp-spelling-error">refactoring</span>, <em>&#8220;if you aren&#8217;t <span class="blsp-spelling-error">refactoring</span> how else do you make code changes?&#8221;</em> The truth however, is that not every code change <strong>is</strong> a <span class="blsp-spelling-error">refactoring</span>, nor does it make sense it to be. Even if the code isn&#8217;t <span class="blsp-spelling-error">truely</span> being <span class="blsp-spelling-error">refactored</span>, it is still possible to adopt many of the activities associated with <span class="blsp-spelling-error">refactoring</span>.</p>
<p>Changes made in a <a href="http://pramatr.com/2008/08/17/structured-approaches-to-improving-code-quality/">structured</a> and disciplined manner, offer far more control and are therefore often far more successful. Important questions therefore need to be asked when changes are being proposed. Are the changes being made with the benefit of a suite of automated <a href="http://www.extremeprogramming.org/rules/unittests.html">unit tests</a>? Is each code change being kept as small as possible? Are the code changes being incrementally applied? Are the changes being <a href="http://martinfowler.com/articles/continuousIntegration.html">continuously integrated</a>? Are the <span class="blsp-spelling-error">IDE&#8217;s</span> tools being fully <a href="http://www.ibm.com/developerworks/library/os-ecref/">leveraged</a> to make changes easier? Do other developers understand the approach being used to change the code?</p>
<p>When making changes to code, it&#8217;s very difficult to understand the associated risks without a solid understanding of the approach being proposed. If a project is deemed to be too risky it might be postponed and rescheduled for a more appropriate time. To aid understanding within a team, instead of simply using the word <span class="blsp-spelling-error">refactoring</span> to describe changes, developers need to fully understand the approach they are using. Are they answering yes to the important questions (outlined above), and more importantly, if they aren&#8217;t, is that acceptable?</p>
<p>If the actual approach <strong>is</strong> <span class="blsp-spelling-error">refactoring</span>, that&#8217;s great! It gives other developers some idea about the way potential changes will be made, and the style of approach is well understood. It integrates very nicely with many other <a href="http://www.extremeprogramming.org/map/code.html">best-practices</a> and <a href="http://pramatr.com/2008/08/17/structured-approaches-to-improving-code-quality">structured</a> development techniques. This <em>can</em> significantly reduce the potential risks associated with changes, thus helping prevent the introduction of new bugs. But it <strong>is</strong> also acceptable to make changes that aren&#8217;t <span class="blsp-spelling-error">refactoring</span>, whilst performing many of the same activities. It is therefore vitally important that developers talk about changes in context, and make them in a structured and disciplined manner, regardless of the name being applied to the approach.</p>
<p>If you are <span class="blsp-spelling-error">refactoring</span> great, if you aren&#8217;t <strong>don&#8217;t</strong> be afraid to use a more appropriate word instead!</p>
<p><strong>Motivation behind the post:</strong></p>
<p>Following a few comments regarding this post, I want to clarify the motivation behind it. I&#8217;ve known about <span class="blsp-spelling-error">refactoring</span> for a good number of years, and I&#8217;ve also often claimed to be <span class="blsp-spelling-error">refactoring</span>. Last week I found myself talking about <span class="blsp-spelling-error">refactoring</span> completely out of context and I was basically playing the role of the developer in the mock conversation. I was claiming to <span class="blsp-spelling-error">refactor</span> some code, but actually this wasn&#8217;t the case at all. Some of the code was rewritten, other changes were unstructured, all without the benefit of unit tests. By telling people I was <span class="blsp-spelling-error">refactoring</span>, I was giving an impression of control where non-existed, I personally don&#8217;t see this as a good thing! In this situation, I believe it&#8217;s much better to come clean and admit you are making unstructured changes, and if possible rectify the situation.</p>
<p><strong>Testing without <span class="blsp-spelling-error">refactoring</span>:</strong></p>
<p>Another point that was raised, was that I had suggested if you don&#8217;t have unit tests you aren&#8217;t <span class="blsp-spelling-error">refactoring</span>. I don&#8217;t think I did suggest this, but I thought it was worth clarif<br />
ying the point. It is completely possible to <span class="blsp-spelling-error">refactor</span> without tests, but as many other people have commented, it&#8217;s dangerous, it&#8217;s <a href="http://www.symphonious.net/2006/03/22/refactoring-without-tests/">scary</a>, difficult and time consuming. This is obviously dependent on the nature of the <span class="blsp-spelling-error">refactoring</span>.</p>
<p>If the <span class="blsp-spelling-error">refactoring</span> is a simple rename method, it is typically assumed to be fairly safe. I&#8217;ve made this mistake before and broken code when making changes, simply because I wasn&#8217;t aware something was called by reflection. I&#8217;ve also broken Spring configuration because the <span class="blsp-spelling-error">AOP</span> used method name matching. Simple changes can still break code, no matter how simple they are!</p>
<p><span class="blsp-spelling-error">Refactoring</span> and testing typically go <a href="http://c2.com/cgi/wiki?TestEveryRefactoring">hand-in-hand</a>, verifying the changes that have been made. It is possible to verify this other ways, but if this is a manual activity it can be extremely time consuming.</p>
<p><strong>Related Links:</strong></p>
<p>After writing this entry, I discovered Marten Fowler documented this phenomenon in a post entitled, <a href="http://martinfowler.com/bliki/RefactoringMalapropism.html"><span class="blsp-spelling-error">RefactoringMalapropism</span></a>. For anyone that&#8217;s a fan of the <a href="http://martinfowler.com/bliki/SemanticDiffusion.html">semantic diffusion</a> that Martin describes, I&#8217;d just like to add that this was written using an agile blogging technique <img src='http://69.89.31.94/~pramatrc/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> .</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pramatr.com/blog/2008/09/26/yes-you-are-making-changes-but-that-doesnt-make-it-refactoring/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Beware, The Developer Who Isn&#039;t Interested In Development!</title>
		<link>http://www.pramatr.com/blog/2008/08/23/beware-the-developer-who-isnt-interested-in-development/</link>
		<comments>http://www.pramatr.com/blog/2008/08/23/beware-the-developer-who-isnt-interested-in-development/#comments</comments>
		<pubDate>Sat, 23 Aug 2008 21:44:00 +0000</pubDate>
		<dc:creator>pramatr</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Opinion]]></category>
		<category><![CDATA[Discipline]]></category>
		<category><![CDATA[Hiring]]></category>
		<category><![CDATA[Improvement]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Structure]]></category>

		<guid isPermaLink="false">http://pramatr.com/2007/08/23/beware-the-developer-who-isnt-interested-in-development/</guid>
		<description><![CDATA[When I first started my software engineering degree, there were plenty of people I met who simply didn&#8217;t want to be there. After a few months they&#8217;d had enough and moved onto something else, and after a couple of years the classes had halved in size. I&#8217;ve actually met a few people in the industry [...]]]></description>
			<content:encoded><![CDATA[<p>When I first started my software engineering degree, there were plenty of people I met who simply didn&#8217;t want to be there. After a few months they&#8217;d had enough and moved onto something else, and after a couple of years the classes had halved in size. I&#8217;ve actually met a few people in the industry who behave like they don&#8217;t want to be here either, but I was hoping they were in the minority. After speaking to a former colleague however, I&#8217;ve found that the problem might be much worse than I had thought. The contradiction of the developer who isn&#8217;t interested in development.</p>
<p>Let me just start by saying, if you&#8217;ve got this far you really aren&#8217;t one of the people I&#8217;m talking about! Hopefully you&#8217;ll see this as a good thing <img src='http://69.89.31.94/~pramatrc/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> .<br />
<span id="more-82"></span><br />
A previous project I worked on was mainly composed of short-term contract staff. The project saw large staff turnover and the code quality was generally quite poor. Many of the developers simply weren&#8217;t interested in the project and why should they be? Team members that don&#8217;t have to take long term <a href="http://www.extremeprogramming.org/rules/collective.html">ownership</a> of a project don&#8217;t really have to worry about it&#8217;s quality or longevity. They can stumble through a project putting in the minimum amount of effort required to get the job done. They can move onto a new project and leave behind all the problems for someone else. When working with transient staff, you just have to be pragmatic about this, it&#8217;s just life. Some of these staff will be true professionals and give a project their all, others won&#8217;t.</p>
<p>Now I know this sounds like an obvious thing to say, but when putting a team together, you need to hire developers who actually take an interest in what they do! Many people involved in the hiring of staff really don&#8217;t understand this, and instead focus on finding someone who claims to be <a href="http://en.wikipedia.org/wiki/Buzzword_compliant">buzzword compliant</a>. Having the right skills is an obvious requirement, but this isn&#8217;t the only consideration that needs to be made. A large percentage of developers out there, just aren&#8217;t interested in the project they are working on and more importantly they aren&#8217;t interested in software development in general. The more developers I talk to and the more horror stories I hear from them, the more I&#8217;m convinced that these people are on the rise.</p>
<p>Developers that aren&#8217;t interested in what they do, don&#8217;t invest in themselves and don&#8217;t strive to improve not only their skills, but also those of their team mates. They don&#8217;t take pride in the code they develop, and a real danger if you work under a developer like this is that you will stop taking pride in yours as well. They will never read technology blogs or articles, they will never be found viewing DZone, TSS, infoQ and they will never pick up a technology book. They have no interest in development outside the hours of 9am-5pm and they probably never will. They are basically happy treading water, just getting by.</p>
<p>They are probably perfectly nice people and outside of work you might have plenty of things in common with them. In a workplace however, teams incorporating individuals like this are always fighting an uphill battle. The knowledge transfer will always be a one-way process. Opinions in important decisions will seem like a diversion from everything else they could be doing. The most reaction you&#8217;ll ever get in a discussion is a nod of their head or a shrug of their shoulders. In the past I&#8217;ve found this can actually be somewhat infectious and it gradually starts to have a negative effect on the entire team.</p>
<p>You&#8217;ve basically got the worst kind of <a href="http://en.wikipedia.org/wiki/Code_monkey">code monkey</a>. One that doesn&#8217;t really know what they are doing, doesn&#8217;t understand what they should be doing, doesn&#8217;t care that this is the case and just isn&#8217;t interested!</p>
<p>Now if you are a <a href="http://en.wikipedia.org/wiki/Code_monkey">code monkey</a> who&#8217;s happy hacking away for eight hours a day, you aren&#8217;t interested in what you do and you really don&#8217;t want to learn, that&#8217;s absolutely fine and good luck to you! In my experience however, if you want to build a team that&#8217;s going to produce a product of quality and longevity, you need to steer well clear of these people! These people will drain your other team members, slow you down and will generally cost you lots of money!</p>
<p>You&#8217;ll find these people everywhere. They&#8217;ll always be too busy to help, but they won&#8217;t be shy in asking other people to help them. They won&#8217;t want to develop things the same way everyone else does and instead they&#8217;ll develop their own <em>style</em>. They will never want to get their hands dirty and instead want to do the cool R&amp;D jobs. When everyone is too busy to help, instead of rolling up their sleeves they&#8217;ll turn to the wealth of free labour on the Internet forums. The majority of posts on forums are from hard working developers, but you&#8217;ll also spot the other type as well.</p>
<p>So as a cautionary tale, if you have employees who fit this profile, do a quick search on the Internet for package and class names that match your project. You might find nothing, on the other hand you might find the original author of your code on an Internet forum. Why not contact them and offer them a job, you might as well if they are writing code for you anyway.</p>
<p>If someone really isn&#8217;t working out in the team, you <strong>need</strong> to do something about it. The longer this goes on, the greater the negative impact will be on the team. This can very quickly go from one problem to several. If there is a hint of promise at all in this developer (and as an eternal optimist I&#8217;d like to believe there always is), work with them to try and understand what the problems are.</p>
<p>Get them involved in the team: find something they are good at or interested in and try and develop this talent. Encourage them to go off and find out more about this and report this back to the team, make them feel important and make them the subject area expert. You need to do everything you can to make these people integrated and motivated. If nothing interests or motivates your developer you&#8217;re in trouble. If it doesn&#8217;t work out, in many cases it&#8217;s better for these people to do nothing at all, such is their negative impact on team performance. At the end of the day, do you really need people like this in your team?</p>
<p>When you are looking to hire new team members, you need more than just <a href="http://en.wikipedia.org/wiki/Buzzword_compliant">buzzwords</a>. Go for the developer that shows real enthusiasm and interest in what they do. Go for the developer that&#8217;s contributed to open source software or forums to help other people out. Go for the developer who is willing to admit they don&#8217;t know the answer to your question, but they do know how to find it. Go for the developer that asks questions and has opinions on things that matter. Go for the developer who is excited that you have a library of books for them to read. These are the people you can work with, you can encourage and you can help to become better developers. These are the people that will be an asset to your team and will help <strong>you</strong> become a better developer as well. One developer who&#8217;s passionate and highly motivated, is worth so much more than a bunch that aren&#8217;t!</p>
<p>Above all else, avoid the contradiction of the developer who isn&#8217;t interested in development.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pramatr.com/blog/2008/08/23/beware-the-developer-who-isnt-interested-in-development/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
	</channel>
</rss>
