<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.3.2" -->
<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/"
	>

<channel>
	<title>Kris Kemper</title>
	<link>http://blog.kriskemper.com</link>
	<description>Thoughtworker, Agile Philosopher, Hero</description>
	<pubDate>Sun, 07 Dec 2008 18:43:51 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.2</generator>
	<language>en</language>
			<item>
		<title>Finding tests related to code you are changing</title>
		<link>http://blog.kriskemper.com/2008/12/07/finding-tests-related-to-code-you-are-changing/</link>
		<comments>http://blog.kriskemper.com/2008/12/07/finding-tests-related-to-code-you-are-changing/#comments</comments>
		<pubDate>Sun, 07 Dec 2008 18:43:51 +0000</pubDate>
		<dc:creator>Kris Kemper</dc:creator>
		
		<category><![CDATA[General Agile]]></category>

		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://blog.kriskemper.com/2008/12/07/finding-tests-related-to-code-you-are-changing/</guid>
		<description><![CDATA[Often, when working on a well tested codebase, you find that you want to know what tests may exist that test the code you are going to modify.
Often a quick search on usages of a method or class is sufficient. You look at the tests briefly to see what is going on, and then you [...]]]></description>
			<content:encoded><![CDATA[<p>Often, when working on a well tested codebase, you find that you want to know what tests may exist that test the code you are going to modify.</p>
<p>Often a quick search on usages of a method or class is sufficient. You look at the tests briefly to see what is going on, and then you make a new test to assert the new behavior that is going to be added.</p>
<p>Sometimes, when there are a lot of tests, I just prefer to remove the code I&#8217;m going to modify, and see what tests fail.</p>
<p>This technique provides some quick and useful information. For instance:</p>
<ol>
<li>What tests were written that test the code? Are there any applicable tests?</li>
<li>Are there other tests that implicitly test the code and should not?</li>
<li>Are the current tests testing all the conditions?</li>
<li>Is there a test that no longer applies?</li>
<li>Is there a test who&#8217;s expectation are changing? That test can be modified instead of writing a new test.</li>
</ol>
<p>This approach tends to be practical in the case of unit tests, and perhaps a few integration tests that you may know are related. Otherwise, it becomes too expensive to run a long running suite.</p>
<p>An additional benefit is that if you already know of some tests that should be testing some code, you may find a test that meant to test the logic, but for some reason was always passing.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kriskemper.com/2008/12/07/finding-tests-related-to-code-you-are-changing/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Winning the Game</title>
		<link>http://blog.kriskemper.com/2008/11/16/winning-the-game/</link>
		<comments>http://blog.kriskemper.com/2008/11/16/winning-the-game/#comments</comments>
		<pubDate>Mon, 17 Nov 2008 04:55:30 +0000</pubDate>
		<dc:creator>Kris Kemper</dc:creator>
		
		<category><![CDATA[General Agile]]></category>

		<category><![CDATA[Agile]]></category>

		<category><![CDATA[Consulting]]></category>

		<category><![CDATA[Game Theory]]></category>

		<category><![CDATA[Organizational Behavior]]></category>

		<guid isPermaLink="false">http://blog.kriskemper.com/2008/11/16/winning-the-game/</guid>
		<description><![CDATA[I was talking to a fellow Thoughtworker about the challenges of consulting, and I thought that one of his points was interesting. What he basically said is that you have to try to understand the motivations behind all the stakeholders in a project; not everyones primary goal is delivering software, there are many motivating factors [...]]]></description>
			<content:encoded><![CDATA[<p>I was talking to a fellow Thoughtworker about the challenges of consulting, and I thought that one of his points was interesting. What he basically said is that you have to try to understand the motivations behind all the stakeholders in a project; not everyones primary goal is delivering software, there are many motivating factors that drive people. A good consultant will try to understand what their motivations are and then try to unify their goals with successful software delivery.</p>
<p>This made me think about a general organizational &#8220;smell&#8221; in software development. For lack of a better label, I&#8217;ll call it fragmentation of goals. A manager might be juggling multiple projects, of which yours is not the highest priority. QA&#8217;s may be measured based on how many bugs they find, or how many test cases the document. A developer might see a better chance at promotion by going to all the meetings he or she is invited to, moreso than the delivery of features. Entire teams within a project may even be motivated by goals that are not complimentary to the success of the project.</p>
<p>When I was in college, I liked to compare the team projects I was on to games. My goal was making sure that we were winning the game (in that situation, getting an &#8220;A&#8221;). Later in my education, I read <a href="http://www.amazon.com/Agile-Software-Development/dp/0201699699">Agile Software Development by Alistair Cockburn</a>, and he made the analogy that software development is like a cooperative game that we are trying to win. I&#8217;ve always loved that analogy, and I think that it&#8217;s a useful tool in conceptualizing an effective team or project. Much like a team game, software projects must be a coordinated and unified effort amongst individuals to achieve a common goal.</p>
<p>There are three important factors that are core to a team being able to deliver software successfully, and each easily becomes fragmented (I&#8217;m generally using team and project synonimously).</p>
<ol>
<li>Knowing how to win the game</li>
<li>Being motivated to win the game</li>
<li>Having the ability to win the game</li>
</ol>
<p>I&#8217;ll discuss each inline below.</p>
<h2>Knowing how to win the game</h2>
<p>A team or project must know how to &#8220;win the game&#8221; - there has to be acceptance criteria on the results of the teams efforts. Not having this clearly established makes it impossible for people to unite towards winning (I am not implying having all the &#8220;requirements&#8221; - I am talking about a clear understanding of how to accomplish the business goal). Without a clear goal, a team can only work towards something that they hope is right, and everyone may not agree on what that is.</p>
<p>An important aspect of this strategy is to have a single dedicated product owner - someone who can provide a vision of the end goal, and be the final decision maker for what aspects of the product will achieve that goal. This will help not only knowing what to build, but have the ability to prioritize when to build something.</p>
<h2>Being motivated to win the game</h2>
<p>The second part is ensuring that the team is motivated to win the game. The team as a whole will suffer if the individuals are engaging in activities meant to promote their own goals over the goals of the team. There are many, many parts to this. My basic opinion is that measuring an individuals success should be based on their contribution to the team, and the teams success.</p>
<p>It is difficult to make sure that everyone has the incentives to be motivated. It is not enough to hire people and then put them to work on something. You must make sure that they are happy, and personally interested in succeeding. It&#8217;s especially important to make sure that the personal goals and desires of the individuals aligned with the success of the team.</p>
<p>This doesn&#8217;t just apply to individuals. Often large projects involves dividing the project into smaller teams. It&#8217;s not beneficial to set up teams with goals that allows them to succeed while the project fails. The concept that this works is often an attempt to suboptimize a system - the idea that if the individual components are succeeding then the whole will succeed. This approach is flawed and often leads to a team achieving it&#8217;s goals, even at the expense of the project.</p>
<h2>Having the ability to win the game</h2>
<p>The team must have the ability to be effective and able to win the game. Further, the team must be empowered to make changes to increase their ability to win the game. The easy example of a team not being able to win is that when the team is formed with people who&#8217;s skill-sets are not suited to success. For example, building a team of people that have never done web development, and asking them to build a sophisticated web application. Another easy example is creating unachievable goals for the team, such as having the scope be too great for the team to ever achieve.</p>
<p>More complicated scenarios involve putting a restriction on a team that they must use a certain language or technology, or to disallow some tools and technologies, without consideration as to whether it actually helps the team succeed. It could even be as simple as the developers not being able to get licenses for software that they need, or computers to support the development efforts.</p>
<p>This point is part of the reason that it is critical for teams to be responsive, continually improving, and honest about what will make them more effective and better able to succeed. It could be that 1 month into a project, the team already knows that it&#8217;s failing and it&#8217;s likely that nothing can be done to help. It could be that the team is producing features, but is losing a lot of time trying to communicate to disparate groups that they rely upon.</p>
<h2>Designing the game</h2>
<p>A final point here is that all of these factors are part of setting up the game in the first place. Often the decisions that are made early on in a projects life sets it up to succeed or to fail. In my experience, the structure of a software project tends to be an extension of the organizational behavior of the company. That structure may not be an ideal structure for a software project.</p>
<p>Regardless of how the project begins, it&#8217;s important to change how the game is played if it is necessary to win the game.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kriskemper.com/2008/11/16/winning-the-game/feed/</wfw:commentRss>
		</item>
		<item>
		<title>When will we have a real multi-user windowing system</title>
		<link>http://blog.kriskemper.com/2008/10/28/when-will-we-have-a-real-multi-user-windowing-system/</link>
		<comments>http://blog.kriskemper.com/2008/10/28/when-will-we-have-a-real-multi-user-windowing-system/#comments</comments>
		<pubDate>Wed, 29 Oct 2008 03:29:55 +0000</pubDate>
		<dc:creator>Kris Kemper</dc:creator>
		
		<category><![CDATA[General]]></category>

		<category><![CDATA[Collaboration]]></category>

		<category><![CDATA[Multi-user desktop]]></category>

		<category><![CDATA[Multiple cursors]]></category>

		<guid isPermaLink="false">http://blog.kriskemper.com/2008/10/28/when-will-we-have-a-real-multi-user-windowing-system/</guid>
		<description><![CDATA[I once worked on a VNC type application, where the purpose was to allow some number of users to share any desktop application to a group of people (part of the allure is that windows applications could be shared to Linux users). The features that were meant to set it apart from the typical desktop [...]]]></description>
			<content:encoded><![CDATA[<p>I once worked on a VNC type application, where the purpose was to allow some number of users to share any desktop application to a group of people (part of the allure is that windows applications could be shared to Linux users). The features that were meant to set it apart from the typical desktop sharing application like VNC was that it would enhance collaboration amongst the users.</p>
<p>It was a fun application to write - It had a Java Swing front end with JNI to use portions of the win32 API and X-Windows API, and we wrote a video and audio server to distribute the view of the application and allow the users to talk to each other in on online group phone call while they were using the application.</p>
<p>There was one desired feature that we could not implement. We wanted to allow users to simultaneously enter text, and simultaneously control their own mouse cursor to interact with the application. We were completely blocked on this feature because it goes against a major assumption of all major operating systems - that one user will use the system at a time. For instance, it&#8217;s assumed that one window will have focus at a time. It is also assumed that there is only one mouse cursor at a time. There are even more subtle issues that come up, such as there being only one copy and paste buffer.</p>
<p>At the time, I was disappointed, but I didn&#8217;t dwell on it too much. I figured that that level of multi-user collaboration would only service a very small niche market, and that it wasn&#8217;t so bad that we didn&#8217;t have the possibility of better collaboration.</p>
<p>Fast forward to today. I pair program most of the time, and I find myself longing for an environment that would allow me and my pair to collaborate in different ways. It&#8217;s standard pair programming, where we both work on the same window, and have to share the same keyboard and mouse input (preferably with 2 mice and 2 keyboards). So what do you do when one person has to check email, or one person decides to research an issue online, or otherwise engage in a task that is not the same as the other pair member? Typically, each person will have a laptop that they can use for these situations, but that causes the person to separate themselves from the primary work environment. Sharing information will have to done by sending an email or putting a file on a shared drive, or having the other person look at information on the laptop&#8217;s screen. What about spiking a problem side by side, where each pair tries two similar but different approaches to solving a programming problem? I would prefer to collaborate with someone in the same environment, where we can do some different tasks in parallel, and can share windows, applications, and data in the same desktop environment.</p>
<p>I think that it would be interesting to expand this idea even further. What if an entire team worked in the same environment, on the same desktop? Each person could have a portion of a huge desktop, and people in a team could choose to collaborate with each other in a very fluid fashion by putting their desktop spaces close together. It would be an interesting experiment in collaboration applied to software development.</p>
<p>Even if multiple simultaneous mouse and keyboard input were generally possible in operating systems, there would still likely be a lot of complex concurrency issues for developers, such as making sure that servers bind to different ports and write out to different files. It&#8217;s likely that once popular operating systems generally allow the multi-user features I mentioned before, that it would still be preferable to have isolated machines that interact through collaborative software rather then have everyone actually use the same machine.</p>
<p>I&#8217;ve seen software that allows sharing of a the mouse and keyboard across machines, and sharing the copy and paste buffer, but the purpose was to allows one person to connect 2 machines and use them like an extended desktop. Perhaps software like this could be tailored for better collaboration for pair programming or developers on a team not pairing.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kriskemper.com/2008/10/28/when-will-we-have-a-real-multi-user-windowing-system/feed/</wfw:commentRss>
		</item>
		<item>
		<title>An idea for a ruby inspection tool</title>
		<link>http://blog.kriskemper.com/2008/10/25/an-idea-for-a-ruby-inspection-tool/</link>
		<comments>http://blog.kriskemper.com/2008/10/25/an-idea-for-a-ruby-inspection-tool/#comments</comments>
		<pubDate>Sat, 25 Oct 2008 16:40:19 +0000</pubDate>
		<dc:creator>Kris Kemper</dc:creator>
		
		<category><![CDATA[The Art of Programming]]></category>

		<category><![CDATA[code inspection]]></category>

		<category><![CDATA[debugging]]></category>

		<category><![CDATA[Ruby]]></category>

		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://blog.kriskemper.com/2008/10/25/an-idea-for-a-ruby-inspection-tool/</guid>
		<description><![CDATA[Working on some ruby code for a little while, I had an idea for a tool that would be useful.
Basically, what I want is an inspection tool that also has a bundle in textmate, so that I can see the history of objects that are created, as well as interactions in a form that is [...]]]></description>
			<content:encoded><![CDATA[<p>Working on some ruby code for a little while, I had an idea for a tool that would be useful.</p>
<p>Basically, what I want is an inspection tool that also has a bundle in textmate, so that I can see the history of objects that are created, as well as interactions in a form that is searchable and that quickly shows what really happened. It would be like having debugging on all the time.</p>
<p>The goal of this tool would be to allow developers to view what really happens with the code when it executes. Sometimes finding the source of bugs is difficult because statically analyzing code is not the easiest way to predict the future state of an object, or to predict the interactions between objects. You don&#8217;t really know what happens until the code executes.</p>
<p>Nor is traditional debugging an efficient way to get the information that you need. You have to set a break-point, add in a line to call the a debugger, or even print out some information in order to answer a question about the actual execution of the code.</p>
<p>What I want is a tool that records a wealth of data about the actual execution of some code, such as when I run a test, or initiate an action from a controller. Then, I would like to be able to filter/query that information to get more precise information.</p>
<p>For the inspection tool, I&#8217;d like to know things like:</p>
<p>- See the actual methods and fields of a class or object instance at the beginning and end of code execution<br />
- See all calls made to an object, or a specific instance of an object<br />
- See all callers of a specific method of a specific object type or object instance<br />
- Detect changes in the structure of an individual object that happens, such as methods being added or redefined after the object is initialized<br />
- View all changes to fields of an object<br />
- I would like to see the order that objects are created in. I would like to see when all objects of a certain type were created, or objects that respond to a specific method<br />
- I would like to see all interactions between 2 objects<br />
- I would like to be able to further scope the search, so that I only see information within the scope of a specific method call</p>
<p>Preferably, I would want to be able to view all of this information after running the code one time. And then be able to enter some search criteria into a form and have it reduce the amount of information to match my search criteria. Then, I can tweak some starting data in a test, and then rerun the test and get a new set of information to query.</p>
<p>I think that most of this information could be obtained by creating a Module to intercept all method sends to every object, and save some data about the context of the call when it&#8217;s made. Then, a client tool could parse the output, and allow a developer to query it.</p>
<p>I tried to do some googling to find something like this, but all I found were standard debugging tools, which I don&#8217;t think have the features that I&#8217;m looking for. If anyone knows of something that can do what I want, let me know.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kriskemper.com/2008/10/25/an-idea-for-a-ruby-inspection-tool/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Granularity of Abstractions</title>
		<link>http://blog.kriskemper.com/2008/10/23/granularity-of-abstractions/</link>
		<comments>http://blog.kriskemper.com/2008/10/23/granularity-of-abstractions/#comments</comments>
		<pubDate>Fri, 24 Oct 2008 02:24:17 +0000</pubDate>
		<dc:creator>Kris Kemper</dc:creator>
		
		<category><![CDATA[The Art of Programming]]></category>

		<category><![CDATA[java]]></category>

		<category><![CDATA[Refactoring]]></category>

		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://blog.kriskemper.com/2008/10/23/granularity-of-abstractions/</guid>
		<description><![CDATA[In Java, iterating over a collection and collecting some objects based on a condition is a classic example of something to put into a method. Here is an example:

private Collection&#60;Claim&#62; getExpiredClaims&#40;&#41; &#123;
&#160; &#160; List&#60;Claim&#62; expiredClaims = new ArrayList&#60;Claim&#62;&#40;&#41;;
&#160; &#160; for &#40;Claim claim : allClaims&#41; &#123;
&#160; &#160; &#160; &#160; if &#40;claim.isExpired&#40;&#41;&#41; &#123;
&#160; &#160; &#160; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>In Java, iterating over a collection and collecting some objects based on a condition is a classic example of something to put into a method. Here is an example:</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="kw2">private</span> Collection&lt;Claim&gt; getExpiredClaims<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; List&lt;Claim&gt; expiredClaims = <span class="kw2">new</span> ArrayList&lt;Claim&gt;<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <span class="kw1">for</span> <span class="br0">&#40;</span>Claim claim : allClaims<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>claim.<span class="me1">isExpired</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; expiredClaims.<span class="me1">add</span><span class="br0">&#40;</span>claim<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="kw2">return</span> expiredClaims;<br />
<span class="br0">&#125;</span></div>
</div>
<p>In Ruby, you can do this in one line.</p>
<div class="codesnip-container" >
<div class="codesnip">all_claims.<span class="me1">select</span> <span class="br0">&#123;</span> |claim| claim.<span class="me1">expired</span>? <span class="br0">&#125;</span></div>
</div>
<p>It&#8217;s lovely how much more succinct that operation becomes. It can actually get more succinct by using <a href="http://api.rubyonrails.org/classes/Symbol.html">Symbol#to_proc</a>:</p>
<div class="codesnip-container" >
<div class="codesnip">all_claims.<span class="me1">select</span> <span class="br0">&#40;</span>&amp;:expired?<span class="br0">&#41;</span></div>
</div>
<p>There is still the question of whether to move this to a method. Now, moving it to a method doesn&#8217;t reduce multi-line duplication the way it would in the Java example; there is only a minor amount of single line duplication that can be reduced.</p>
<p>The resistance I often get to refactoring a single line to a method is that it creates more total lines in the file with the def/end lines and spacing. Also, it takes a slight amount of effort to do the refactoring, and some developers won&#8217;t refactor unless the need is glaring and obvious.</p>
<p>There are still important reasons to move this to a method, and those reasons are better readability of code and reducing duplication of expressions. Without the refactoring, you&#8217;ll see code that looks like this:</p>
<div class="codesnip-container" >
<div class="codesnip">def mark_expired_claims_for_review<br />
&nbsp; &nbsp; all_claims.<span class="me1">select</span> <span class="br0">&#40;</span>&amp;:expired?<span class="br0">&#41;</span>.<span class="me1">each</span><span class="br0">&#40;</span>&amp;:needs_review!<span class="br0">&#41;</span><br />
end</p>
<p>def notify_claim_agents_of_expired_claims<br />
&nbsp; &nbsp; all_claims.<span class="me1">select</span> <span class="br0">&#40;</span>&amp;:expired?<span class="br0">&#41;</span>.<span class="me1">each</span><span class="br0">&#40;</span>&amp;:notify_agent_of_expiration<span class="br0">&#41;</span><br />
end</div>
</div>
<p>After the refactoring, this is what it would look like.</p>
<div class="codesnip-container" >
<div class="codesnip">def expired_claims<br />
&nbsp; &nbsp; all_claims.<span class="me1">select</span><span class="br0">&#40;</span>&amp;:expired?<span class="br0">&#41;</span><br />
end</p>
<p>def mark_expired_claims_for_review<br />
&nbsp; &nbsp; expired_claims.<span class="me1">each</span><span class="br0">&#40;</span>&amp;:needs_review!<span class="br0">&#41;</span><br />
end</p>
<p>def notify_claim_agents_of_expired_claims<br />
&nbsp; &nbsp; expired_claims.<span class="me1">each</span><span class="br0">&#40;</span>&amp;:notify_agent_of_expiration<span class="br0">&#41;</span><br />
end</div>
</div>
<p>It&#8217;s a minor point perhaps, and I&#8217;m sure that I could come up with much more excessive examples, but I just wanted to focus on a simple example. By replacing the expression with a symbolic reference, a method in this case, you express in English something that is a programmatic operation. This improves readability quite a bit.</p>
<p>Also, there is the additional benefit of abstracting on the concept of expired claims. By having multiple places using &#8220;all_claims.select(&#038;:expired?)&#8221; to express expired claims, you duplicate the implementation detail that expired claims are derived from a larger collection of claims. This may not always be true, and a change in that derivation results in a change in many places.</p>
<p>Perhaps the question here is how DRY should you make your code. I&#8217;m still undecided on this on this point, but I think that the amount of work that it takes to reduce duplication to this level is minimal, and the result will be an important part of a pristine codebase.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kriskemper.com/2008/10/23/granularity-of-abstractions/feed/</wfw:commentRss>
		</item>
		<item>
		<title>That&#8217;s stupid</title>
		<link>http://blog.kriskemper.com/2008/10/22/thats-stupid/</link>
		<comments>http://blog.kriskemper.com/2008/10/22/thats-stupid/#comments</comments>
		<pubDate>Thu, 23 Oct 2008 02:34:36 +0000</pubDate>
		<dc:creator>Kris Kemper</dc:creator>
		
		<category><![CDATA[General Agile]]></category>

		<guid isPermaLink="false">http://blog.kriskemper.com/2008/10/22/thats-stupid/</guid>
		<description><![CDATA[I meet a lot of developers (or IT people in general) that make this statement. It&#8217;s a reoccurring personality trait. Some do it more than others. It&#8217;s annoying. I don&#8217;t consider myself a &#8220;strong&#8221; personality, and as part of that, I hesitate to call anything stupid. I like to ponder topics for a while before [...]]]></description>
			<content:encoded><![CDATA[<p>I meet a lot of developers (or IT people in general) that make this statement. It&#8217;s a reoccurring personality trait. Some do it more than others. It&#8217;s annoying. I don&#8217;t consider myself a &#8220;strong&#8221; personality, and as part of that, I hesitate to call anything stupid. I like to ponder topics for a while before I declare the stupidity at hand. Often, things that seem really stupid have a deeper context that result in their existence. It&#8217;s not as simple as saying that an idea, a person, or an occurrence is stupid; sometime &#8220;stupid&#8221; things come out a culmination of small factors.</p>
<p>Ironically, I often find that the people that make these claims do it out of ignorance. Many of these personality types make these statements and then have people explain to them why it&#8217;s not as stupid as it seems. Even then, a subset of these people will continue to assert that it&#8217;s all stupid.</p>
<p>Strictly speaking, it&#8217;s not a bad technique; I&#8217;ve met many people with this approach who earn validation in their claims from people who trust that they are, in fact, very smart. I don&#8217;t want to discredit some of these people; I&#8217;ve met some that were incredibly intelligent and could successfully back up their claims with both facts and a quick wit.</p>
<p>For many, it&#8217;s an argumentative technique, where they begin an argument basically saying &#8220;I&#8217;m smart, and most of you are stupid, now try to tell me that I&#8217;m wrong.&#8221; When I was a teenager, I started a lot of debates this way. I thought that I was smarter than most, and I felt empowered by this approach.</p>
<p>The problem that I find is that I meet too many developers are not good at it. They are clearly ignorant of the context of their statements, and it shows. They tend to look a lot like the naive teenager that thinks that they know more than they really do. Nor are they often the type of people that you can easily inform of the downside to their approach; Many of them won&#8217;t consider that they are wrong long enough to accept feedback.</p>
<p>Perhaps this bothers me as much as it does because I&#8217;m a consultant. Either it occurs with other consultants, and it demonstrates a lack of consulting skills, or it happens with client employees, where I&#8217;m not in a position to give them completely honest feedback.</p>
<p>Aside from this being a rant, I guess the purpose of this post is to cause some amount of introspection from people out there. Are you putting your ideas out there as best as you can? If you just read this blog post, and you feel like it could apply to you, then think for a while whether you can improve your approach. If you really want your ideas and opinions to have value, then try to articulate them in way that shows that you are cognizant of the factors involved, and are trying to make things better. Otherwise, you run the risk of discrediting yourself, and decreasing your ability to affect change.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kriskemper.com/2008/10/22/thats-stupid/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Automated acceptance testing can be optional for some projects</title>
		<link>http://blog.kriskemper.com/2008/10/20/automated-acceptance-testing-can-be-optional-for-some-projects/</link>
		<comments>http://blog.kriskemper.com/2008/10/20/automated-acceptance-testing-can-be-optional-for-some-projects/#comments</comments>
		<pubDate>Tue, 21 Oct 2008 04:09:13 +0000</pubDate>
		<dc:creator>Kris Kemper</dc:creator>
		
		<category><![CDATA[General Agile]]></category>

		<category><![CDATA[acceptance tests]]></category>

		<category><![CDATA[java]]></category>

		<category><![CDATA[java swing]]></category>

		<category><![CDATA[QA]]></category>

		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://blog.kriskemper.com/2008/10/20/automated-acceptance-testing-can-be-optional-for-some-projects/</guid>
		<description><![CDATA[My experience with acceptance testing is that it usually fills the role of deep integration as well as immediate acceptance of tests. They can serve as both a requirement recording mechanism as well as a regression testing tool. There is a cost associated with them, but you have to consider the context of the project [...]]]></description>
			<content:encoded><![CDATA[<p>My experience with acceptance testing is that it usually fills the role of deep integration as well as immediate acceptance of tests. They can serve as both a requirement recording mechanism as well as a regression testing tool. There is a cost associated with them, but you have to consider the context of the project in deciding whether the costs are justified.</p>
<p>For instance, a public facing application generally requires a higher bar of quality than an internal application. Often, small defects in an internal app can be tolerated, while they can become hugely embarrassing mistakes in the public facing application.</p>
<p>An example for a public facing application: If amazon.com has a bug in whether users can add items to the cart at certain points, it may not be the only way to add items to the cart, but a small bug could result in many missed sales, and an expensive loss to amazon (not to mention the risk of losing shoppers from a poor user experience). An acceptance testing suite that tests on specific small features like that can be very valuable - offsetting the cost of maintenance.</p>
<p>However, some projects may find that they can get away with a reduced mitigation of defects. These projects may also find that they can run acceptably with a small team of QA even without those tests.</p>
<p>For instance, I worked on an internal workflow application. It was a large application in terms of the number of screens and tables (more than 150 tables). It was implemented as a Java Swing thick client that communicated with an apache tomcat server. There were less than 500 users using the application, and all of them were employees of the company. The important consideration was not to have no bugs occur, but to not have any occur that would block a users ability to complete some portion of a business critical workflow. If any defects like that were discovered in production after a release (released every 1 to 2 weeks), we would be able to push out a branched hotfix release to get it working again.</p>
<p>We had 2 - 3 QA&#8217;s and about 12 devs. They were unable to manually do a full regression test run since they had over 10,000 test cases (which would take months to test manually), so they focused on testing what they knew changed, and doing a quick happy path test of the workflow to make sure.</p>
<p>An additional aspect to this was that developers often helped out in QA. We thoroughly (manually) tested our changes when we were done with a story or bug fix, and often put developers on QA tasks in order to increase testing capacity when needed. One last thing of critical importance; when a developer made changes to the codebase, there was communication to the QA people on how risky the change might be. Low risk changes could get by with a QA testing a single screen briefly, whereas high risk changes would merit greater regression testing of the application. Developers worked with QA to give them better information to help them discover bugs more often.</p>
<p>The project ran well with this approach. There were defects, but almost none of them were critical. In the case of a critical bug occurring, they were quickly resolve with little cost.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kriskemper.com/2008/10/20/automated-acceptance-testing-can-be-optional-for-some-projects/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Getting rid of switch statements with Java Enums</title>
		<link>http://blog.kriskemper.com/2008/10/19/getting-rid-of-switch-statements-with-java-enums/</link>
		<comments>http://blog.kriskemper.com/2008/10/19/getting-rid-of-switch-statements-with-java-enums/#comments</comments>
		<pubDate>Sun, 19 Oct 2008 23:28:22 +0000</pubDate>
		<dc:creator>Kris Kemper</dc:creator>
		
		<category><![CDATA[The Art of Programming]]></category>

		<category><![CDATA[instance initializers]]></category>

		<category><![CDATA[java]]></category>

		<category><![CDATA[Java enums]]></category>

		<category><![CDATA[polymorphism]]></category>

		<category><![CDATA[static initializer]]></category>

		<guid isPermaLink="false">http://blog.kriskemper.com/2008/10/19/getting-rid-of-switch-statements-with-java-enums/</guid>
		<description><![CDATA[I recently saw an interesting and polymorphic way to get rid of using a case statement when using enums. This is possible by defining a method for each instance of an enum.
I&#8217;m sure that you have seen code like this:

enum Friend &#123;
&#160; &#160; Joey, Chandler;
&#125;

And then somewhere in the code, you might see:

class SomeObjectThatNeedsToKnowBestFriends &#123;
&#160; [...]]]></description>
			<content:encoded><![CDATA[<p>I recently saw an interesting and polymorphic way to get rid of using a case statement when using enums. This is possible by defining a method for each instance of an enum.</p>
<p>I&#8217;m sure that you have seen code like this:</p>
<div class="codesnip-container" >
<div class="codesnip">enum Friend <span class="br0">&#123;</span><br />
&nbsp; &nbsp; Joey, Chandler;<br />
<span class="br0">&#125;</span></div>
</div>
<p>And then somewhere in the code, you might see:</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="kw2">class</span> SomeObjectThatNeedsToKnowBestFriends <span class="br0">&#123;</span></p>
<p>&nbsp; &nbsp; <span class="kw4">void</span> doSomethingWithBestFriends<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">for</span> <span class="br0">&#40;</span>Friend friend : Friend.<span class="me1">values</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; doSomething<span class="br0">&#40;</span>bestFriend<span class="br0">&#40;</span>friend<span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; Friend bestFriend<span class="br0">&#40;</span>Friend friend<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="kw1">switch</span> <span class="br0">&#40;</span>friend<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="kw1">case</span> Joey: <span class="kw2">return</span> Friend.<span class="me1">Chandler</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="kw1">case</span> Chandler: <span class="kw2">return</span> Friend.<span class="me1">Joey</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;default: <span class="kw2">throw</span> <span class="kw2">new</span> <a href="http://www.google.com/search?q=allinurl%3ARuntimeException+java.sun.com&#038;bntl=1"><span class="kw3">RuntimeException</span></a><span class="br0">&#40;</span><span class="st0">&#8220;This person has no friend&#8221;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div>
</div>
<p>This is a common smell in a code base where client code has logic that should be better encapsulated. Now, whenever someone adds a friend, they are going to have to search for references on Friends and add a new entry, or they are going to get a RuntimeException from the switch statement. In a well tested codebase, there is probably going to be a unit test that asserts that all Friends have best friends. In any case, the switch statement in the client object code is not great from an OO standpoint and it creates a maintainability issue.</p>
<p>The first refactoring is to move all Friend related logic to the Friend enum where it belongs.</p>
<div class="codesnip-container" >
<div class="codesnip">enum Friend <span class="br0">&#123;</span><br />
&nbsp; &nbsp; Joey, Chandler;</p>
<p>&nbsp; &nbsp; Friend bestFriend<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="kw1">switch</span> <span class="br0">&#40;</span><span class="kw2">this</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="kw1">case</span> Joey: <span class="kw2">return</span> Chandler;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="kw1">case</span> Chandler: <span class="kw2">return</span> Joey;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;default: <span class="kw2">throw</span> <span class="kw2">new</span> <a href="http://www.google.com/search?q=allinurl%3ARuntimeException+java.sun.com&#038;bntl=1"><span class="kw3">RuntimeException</span></a><span class="br0">&#40;</span><span class="st0">&#8220;This person has no friend&#8221;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p><span class="br0">&#125;</span></div>
</div>
<p>Now, we can just ask the Friend who their best friend is.</p>
<div class="codesnip-container" >
<div class="codesnip">Joey.<span class="me1">bestFriend</span><span class="br0">&#40;</span><span class="br0">&#41;</span>; &#8211;&gt; returns Chandler;</div>
</div>
<p>Nice. Still, I&#8217;m not wild about that switch statement. Developers still have to know to update it, and really, I&#8217;d rather not even have to throw an exception because it was misused. It would be better if the structure of the code did not allow misuse.</p>
<p>Here is an example of how to do this:</p>
<div class="codesnip-container" >
<div class="codesnip">enum Friend <span class="br0">&#123;</span><br />
&nbsp; &nbsp; Joey <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Friend bestFriend<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="kw2">return</span> Chandler; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span>,<br />
&nbsp; &nbsp; Chandler <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Friend bestFriend<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="kw2">return</span> Joey; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="kw2">abstract</span> Friend bestFriend<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></div>
</div>
<p>Then,</p>
<div class="codesnip-container" >
<div class="codesnip">Joey.<span class="me1">bestFriend</span><span class="br0">&#40;</span><span class="br0">&#41;</span>; &#8211;&gt; returns Chandler;</div>
</div>
<p>Great, now we know that when someone adds a new friend, they will immediately be confronted with having to supply a best friend. My only issue with this approach is that all the method definitions become verbose when you introduce many methods like this. I tried different approaches to solving this problem, but due to the enums referencing each other, I was not able to do a different approach.</p>
<p>Here is an example of what you can&#8217;t do:</p>
<div class="codesnip-container" >
<div class="codesnip">enum Friend <span class="br0">&#123;</span><br />
&nbsp; &nbsp; Joey <span class="br0">&#40;</span>Chandler<span class="br0">&#41;</span>,<br />
&nbsp; &nbsp; Chandler<span class="br0">&#40;</span>Joey<span class="br0">&#41;</span></p>
<p>&nbsp; &nbsp; <span class="kw2">final</span> Friend bestFriend;</p>
<p>&nbsp; &nbsp; Friend<span class="br0">&#40;</span>Friend bestFriend<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">this</span>.<span class="me1">bestFriend</span> = bestFriend;<br />
&nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; Friend bestFriend<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">return</span> bestFriend;<br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div>
</div>
<p>This won&#8217;t work because you can&#8217;t reference Chandler in the enum definition for Joey. The Chandler Enum hasn&#8217;t been defined yet, so this won&#8217;t even compile. However, you can &#8220;trick&#8221; the compiler by fully referencing Chandler using Friend.Chandler;</p>
<div class="codesnip-container" >
<div class="codesnip">enum Friend <span class="br0">&#123;</span><br />
&nbsp; &nbsp; Joey <span class="br0">&#40;</span>Friend.<span class="me1">Chandler</span><span class="br0">&#41;</span>,<br />
&nbsp; &nbsp; Chandler<span class="br0">&#40;</span>Joey<span class="br0">&#41;</span></p>
<p>&nbsp; &nbsp; <span class="kw2">final</span> Friend bestFriend;</p>
<p>&nbsp; &nbsp; Friend<span class="br0">&#40;</span>Friend bestFriend<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">this</span>.<span class="me1">bestFriend</span> = bestFriend;<br />
&nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; Friend bestFriend<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">return</span> bestFriend;<br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div>
</div>
<p>However, the result is not what we want:</p>
<p>Joey.bestFriend(); &#8211;> null<br />
Chandler.bestFriend(); &#8211;> Joey</p>
<p>Even though I can reference the other enum instance this way, it resolves to null. The reason lies in the fact that when the Enum is compiled, each instance is a static final field, and initialized in a static block. Here is a snippet of the generated code:</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="kw2">public</span> <span class="kw4">static</span> <span class="kw2">final</span> Friend Joey;<br />
&nbsp; &nbsp; <span class="kw2">public</span> <span class="kw4">static</span> <span class="kw2">final</span> Friend Chandler;<br />
&nbsp; &nbsp; <span class="kw2">final</span> Friend bestFriend;<br />
&nbsp; &nbsp; <span class="kw2">private</span> <span class="kw4">static</span> <span class="kw2">final</span> Friend ENUM$VALUES<span class="br0">&#91;</span><span class="br0">&#93;</span>;</p>
<p>&nbsp; &nbsp; <span class="kw4">static</span><br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Joey = <span class="kw2">new</span> Friend<span class="br0">&#40;</span><span class="st0">&#8220;Joey&#8221;</span>, <span class="nu0">0</span>, Chandler<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; Chandler = <span class="kw2">new</span> Friend<span class="br0">&#40;</span><span class="st0">&#8220;Chandler&#8221;</span>, <span class="nu0">1</span>, Joey<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; ENUM$VALUES = <span class="br0">&#40;</span><span class="kw2">new</span> Friend<span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Joey, Chandler<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#125;</span></div>
</div>
<p>Interestingly, I can write a program that tries the fully qualified name for explicit static constants, and it works:</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="kw2">public</span> <span class="kw2">class</span> StaticEnumClass <span class="br0">&#123;</span></p>
<p>&nbsp; &nbsp; <span class="kw4">static</span> <span class="kw2">final</span> <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&#038;bntl=1"><span class="kw3">String</span></a> foobar = <span class="st0">&#8220;foo&#8221;</span> + StaticEnumClass.<span class="me1">bar</span>;<br />
&nbsp; &nbsp; <span class="kw4">static</span> <span class="kw2">final</span> <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&#038;bntl=1"><span class="kw3">String</span></a> bar = <span class="st0">&#8220;bar&#8221;</span>;<br />
&nbsp; &nbsp;<br />
&nbsp; &nbsp; <span class="kw2">public</span> <span class="kw4">static</span> <span class="kw4">void</span> main<span class="br0">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&#038;bntl=1"><span class="kw3">String</span></a><span class="br0">&#91;</span><span class="br0">&#93;</span> args<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?q=allinurl%3ASystem+java.sun.com&#038;bntl=1"><span class="kw3">System</span></a>.<span class="me1">out</span>.<span class="me1">println</span><span class="br0">&#40;</span>foobar<span class="br0">&#41;</span>; <span class="co1">// prints out &quot;foobar&quot;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp;<br />
<span class="br0">&#125;</span></div>
</div>
<p>But if I use a static initialization, it doesn&#8217;t:</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="kw2">public</span> <span class="kw2">class</span> StaticEnumClass <span class="br0">&#123;</span></p>
<p>&nbsp; &nbsp; <span class="kw4">static</span> <span class="kw2">final</span> <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&#038;bntl=1"><span class="kw3">String</span></a> foobar;<br />
&nbsp; &nbsp; <span class="kw4">static</span> <span class="kw2">final</span> <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&#038;bntl=1"><span class="kw3">String</span></a> bar;<br />
&nbsp; &nbsp;<br />
&nbsp; &nbsp; <span class="kw4">static</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; foobar = <span class="st0">&#8220;foo&#8221;</span> + StaticEnumClass.<span class="me1">bar</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; bar = <span class="st0">&#8220;bar&#8221;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp;<br />
&nbsp; &nbsp; <span class="kw2">public</span> <span class="kw4">static</span> <span class="kw4">void</span> main<span class="br0">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&#038;bntl=1"><span class="kw3">String</span></a><span class="br0">&#91;</span><span class="br0">&#93;</span> args<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?q=allinurl%3ASystem+java.sun.com&#038;bntl=1"><span class="kw3">System</span></a>.<span class="me1">out</span>.<span class="me1">println</span><span class="br0">&#40;</span>foobar<span class="br0">&#41;</span>; <span class="co1">// prints &quot;foonull&quot;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp;<br />
<span class="br0">&#125;</span></div>
</div>
<p>Interesting. The compiler is smart enough to resolve the correct value when you don&#8217;t use a static initialization block. Back to my original example with Friends. The next attempt was to create an anonymous constructor (actually, an instance initializer) for the enum instances and see if I could get what I want:</p>
<div class="codesnip-container" >
<div class="codesnip">enum Friend <span class="br0">&#123;</span><br />
&nbsp; &nbsp; Joey <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bestFriend = Chandler;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span>,<br />
&nbsp; &nbsp; Chandler <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bestFriend = Joey;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; Friend bestFriend;</p>
<p>&nbsp; &nbsp; Friend bestFriend<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">return</span> bestFriend;<br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div>
</div>
<p>I had to remove the final from bestFriend, since I&#8217;m inializing the value when the object is instantiated using an instance initializer. This compiles, and seems like an okay approach. My hope was that the references to other enum types would get resolved in much the same manner as in the case of creating a method that returns each one. Interestingly, this doesn&#8217;t happen.</p>
<div class="codesnip-container" >
<div class="codesnip">Joey.<span class="me1">bestFriend</span><span class="br0">&#40;</span><span class="br0">&#41;</span>; &#8211;&gt; <span class="kw2">null</span><br />
Chandler.<span class="me1">bestFriend</span><span class="br0">&#40;</span><span class="br0">&#41;</span>; &#8211;&gt; Joey</div>
</div>
<p>The reason is that even though I am using an instance initializer, it&#8217;s being called from a static block since the instances are created in a static block. Turns out to be a naive attempt. Here is what it ends up looking like when the enum gets generated as a class:</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="kw4">static</span><br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Joey = <span class="kw2">new</span> Friend<span class="br0">&#40;</span><span class="st0">&#8220;Joey&#8221;</span>, <span class="nu0">0</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bestFriend = Friend.<span class="me1">Chandler</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
;<br />
&nbsp; &nbsp; &nbsp; &nbsp; Chandler = <span class="kw2">new</span> Friend<span class="br0">&#40;</span><span class="st0">&#8220;Chandler&#8221;</span>, <span class="nu0">1</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bestFriend = Friend.<span class="me1">Joey</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
;<br />
&nbsp; &nbsp; &nbsp; &nbsp; ENUM$VALUES = <span class="br0">&#40;</span><span class="kw2">new</span> Friend<span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Joey, Chandler<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#125;</span></div>
</div>
<p>Oh well. That&#8217;s as far as my experimentation went. I&#8217;m satisfied that I can at least create an anonymous subtype of an enum that returns the correct value, but if anyone has any ideas on how to do this in a cleaner way, let me know.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kriskemper.com/2008/10/19/getting-rid-of-switch-statements-with-java-enums/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Saving lost developer time with better hardware</title>
		<link>http://blog.kriskemper.com/2008/10/04/saving-lost-developer-time-with-better-hardware/</link>
		<comments>http://blog.kriskemper.com/2008/10/04/saving-lost-developer-time-with-better-hardware/#comments</comments>
		<pubDate>Sat, 04 Oct 2008 21:22:13 +0000</pubDate>
		<dc:creator>Kris Kemper</dc:creator>
		
		<category><![CDATA[General Agile]]></category>

		<guid isPermaLink="false">http://blog.kriskemper.com/2008/10/04/saving-lost-developer-time-with-better-hardware/</guid>
		<description><![CDATA[A common problem that I see on projects is that the computers available to the teams are mediocre. The obvious example of this is when the computers given to developers are mediocre, but I also think that there is a compelling point to be made around solving performance on build machines with hardware instead of [...]]]></description>
			<content:encoded><![CDATA[<p>A common problem that I see on projects is that the computers available to the teams are mediocre. The obvious example of this is when the computers given to developers are mediocre, but I also think that there is a compelling point to be made around solving performance on build machines with hardware instead of software.</p>
<h2>Developer Machines</h2>
<p>I was once on a project where the local update and build process became an hour long. I won&#8217;t get into the details, but it was largely an IO bound delay, with portions with the processor as the bottleneck. We were using Dell 610 laptops. When some developers started gettting Dell 620&#8217;s (dual core laptops), we discovered that it reduced the local build time on the machines by 33% to 50%. Whoa.</p>
<p>Think about that. A 60 minute build cut down to 30 minutes. Let&#8217;s assume that developers only build once per day and that each developer has an average cost of $100 per hour (total cost to the organization, not just wages). With those savings, getting every developer a Dell 620 instead of a Dell 610 pays for itself in couple weeks. This is just considered cutting a long build in half. There are many other situations where having a slow machine causes lost developer time.</p>
<p>We lobbied for getting the developers better machines, and were mostly denied. I discovered that organizations measure the cost of people separate from the cost of hardware. In fact, they may be accounted for by different departments entirely, where an arbitrary budget is given to the department that issues employee computers.</p>
<p>I&#8217;ve seen this on every project I&#8217;ve been on. We are given slow machines, and time is lost. It may be lost because I&#8217;m running grep over a lot of files, it may be because when I have my all my development tools open and the machine slows down.</p>
<p>I think that it&#8217;s fine that organizations begin developers with cheap machines, but they should be quick to spend money at the first sign that it is needed by the developers. I believe that it is an aspect of agility that many organizations fall short on, where the ability to respond to constraints in the software development system is hindered by the structure and policies of the organization.</p>
<p>In fact, I think that IT organizations should do a few tests against their technology stack and see what kind of performance difference exist, and use those numbers to decide what kind of machines that developers can use that will result in the best performance while being reasonable on cost. This is especially true of Java J2EE projects, as most of the tools and applications are intensive, and the time it takes to build an entire application can be intensive.</p>
<h2>Build Machines</h2>
<p>If your project has any kind of continuous integration (and it should!) then you have probably felt the pain of long builds at some point. I&#8217;ve seen this on every project I&#8217;ve been on. There are two areas in particular that I&#8217;ve found to be painful: Long running regression or acceptance tests, and long compilation and deployment cycles due to heavyweight tools.</p>
<p>Often builds and tests are segmented into builds that are run locally on developer machines, and builds that are run by the build server. A typical approach is to have developers run unit tests and fast running integration tests locally while developing, but to have long running integration tests and acceptance tests run by a build server, where failures will be fixed later by developers when the build completes.</p>
<p>Many projects will find over time that the time it takes to run these large integration tests and acceptance tests becomes so long that the value is reduced. The time it takes to get feedback might be hours or even days. Often, these tests are failing, as by the time they complete, multiple developers or teams may made changes that break a portion of the test suite.</p>
<p>I&#8217;ve seen or read of different approaches to this problem, from using in-memory databases, to manually splitting the regression suites into separate builds or &#8220;pipelines&#8221;, to <a href="http://en.wikipedia.org/wiki/Distributed_computing">distributed computing</a>, to transparent parallelization of tests.</p>
<p>An example of a new tool for transparently running tests in parallel is the <a href="http://selenium-grid.openqa.org/">Selenium Grid</a> which attempts to run selenium tests in parallel. While I think there is merit in exploring these tools, they are non-trivial to setup and maintain, and while it may result in the build/test time being cut down to a fraction of it&#8217;s original time, it increases the complexity of the infrastructure that developers will have to maintain. There tends to be surprise issues with parallization as well. You have to make sure that you can have tests that are writing to the filesystem, querying a database, or calling other services in parrallel.</p>
<p>One day, I hope to try a different approach. I would rather spend the money trying to use hardware to solve the problem instead of using some complicated tool. From a previous experience of dealing with an incredibly IO bound build, I&#8217;ve long dreamt of building a hard drive out of RAM. I&#8217;m not talking about using flash memory; I&#8217;m talking about using DDR RAM instead of a traditional hard drive.</p>
<p>I recently looked into this concept, and I found that there are a few manufacturers out there that provide devices to do this very thing, such as the <a href="http://www.hyperossystems.co.uk/07042003/hardware.htm#hyperosHDIIproduct">Hyper Drive 4</a>. There are a few other devices out there that can achieve this, but I liked the information/propaganda on the Hyper Drive page the best.</p>
<p>The <a href="http://www.hyperossystems.co.uk/07042003/hardware.htm#">stats</a> claimed by using a RAM based hard disk are nothing short of sexy.</p>
<p>I won&#8217;t reiterate the numbers here, but depending on the usage, it ranges from an order of magnitude to several orders of magnitude in increased performance. Even in builds and test suites that are not predominately IO bound, I am willing to bet that the performance boost to the operating system will translate into large gains for the performance of the tests. My favorite statistic was that Windows XP booted in 2 seconds with their test configuration, and that was only because of device polling.</p>
<p>I don&#8217;t think that the cost of such as system is unreasonable. One 16 gigabyte drive using the Hyper Drive system would probably cost around $5000. Assuming an average developer cost of $100 dollars an hour, it pays for itself if one week of 1 developers time is saved, let alone considering the benefits to an entire team. Come to think of it, I would argue that developers should have similar setups for their local machines. For instance, grep would probably be instantaneous with a DDR based drive.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kriskemper.com/2008/10/04/saving-lost-developer-time-with-better-hardware/feed/</wfw:commentRss>
		</item>
		<item>
		<title>An &#8220;old school&#8221; technique for testing summation</title>
		<link>http://blog.kriskemper.com/2008/09/20/an-old-school-technique-for-testing-summation/</link>
		<comments>http://blog.kriskemper.com/2008/09/20/an-old-school-technique-for-testing-summation/#comments</comments>
		<pubDate>Sat, 20 Sep 2008 17:59:30 +0000</pubDate>
		<dc:creator>Kris Kemper</dc:creator>
		
		<category><![CDATA[The Art of Programming]]></category>

		<category><![CDATA[bitwise operations]]></category>

		<category><![CDATA[summation]]></category>

		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://blog.kriskemper.com/2008/09/20/an-old-school-technique-for-testing-summation/</guid>
		<description><![CDATA[I wrote some tests a few weeks back where I had to sum up a bunch of values on a collection of objects and assert that the summation happened correctly. A naive way to do this is to build the test objects with all the values equal to 1, sum them, and assert that the [...]]]></description>
			<content:encoded><![CDATA[<p>I wrote some tests a few weeks back where I had to sum up a bunch of values on a collection of objects and assert that the summation happened correctly. A naive way to do this is to build the test objects with all the values equal to 1, sum them, and assert that the total is the same as the number of objects created for the test.</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="kw4">int</span> calculateClaimTotal<span class="br0">&#40;</span>List&lt;Claim&gt; claims<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">int</span> total = <span class="nu0">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">for</span> <span class="br0">&#40;</span>Claim claim : claims<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; total += claim.<span class="me1">getAmount</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">return</span> total;<br />
<span class="br0">&#125;</span></div>
</div>
<p>In this example, you could test calculateClaimTotal by creating 3 claims with amounts = 1, and assert that the total is 3.</p>
<p>This may seem sufficient for a simple summation, but it becomes more flawed when the summation becomes based on business rules. Now, if the values to be summed are all 1, you can&#8217;t differentiate which rules were enforced by looking at the resulting number directly.</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="kw4">int</span> calculateClaimTotal<span class="br0">&#40;</span>List&lt;Claim&gt; claims<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">int</span> total = <span class="nu0">0</span>;&nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">for</span> <span class="br0">&#40;</span>Claim claim : claims<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>claim.<span class="me1">isActive</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; total += claim.<span class="me1">getAmount</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">return</span> total;<br />
<span class="br0">&#125;</span></div>
</div>
<p>Now, we want to be able to differentiate that the active claims are the ones that get summed. This can become a bloated assertion to make. For instance, you can extend the test objects and count invocations on getAmount(). Then, you can assert that only the objects you expected where used to calculate the total.</p>
<p>A much simpler way of asserting that the objects that you expected were the ones that were used is to use amount values that, when summed, always have a distinct result. This is achieved by using numbers that map to distinct bitwise values:</p>
<p>00001 = 1<br />
00010 = 2<br />
00100 = 4<br />
01000 = 8<br />
10000 = 16</p>
<p>There is no way to add any of these numbers and have them be equal to any other summation of a subset of the numbers. This is because addition of 2 of these numbers is equivalent to an &#8220;or&#8221; operation on the bits of the numbers:</p>
<p>   00001 = 1<br />
   00010 = 2<br />
 +__________<br />
   00011 = 3</p>
<p>This characteristic allows me to identify exactly what claims where used in the summation, because the resulting value could only occur from the values I expect:</p>
<p>Claim 1 is active with value = 1<br />
Claim 2 is inactive with value = 2<br />
Claim 3 is active with value = 4</p>
<p>I can assert that calculateClaimTotal will return 5 here, and that 5 will occur if and only if Claim 1 and Claim 3 are the ones used for the summation. Essentially, a bit location set to 1 instead of 0 will uniquely identify the object that the value came from.</p>
<p>I call this an old school testing technique because these days, there is not a lot of bitwise math that occurs in the course of programming. Back in the day, high performance C programmers would use bitwise operation often, and api&#8217;s such as the win32 api used bitwise math as part of api.</p>
<p>Even in today&#8217;s fancy world of high level abstraction, sometimes it takes a smooth low level trick like this one to achieve the most succinct code.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kriskemper.com/2008/09/20/an-old-school-technique-for-testing-summation/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
