<?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"
	>

<channel>
	<title>cwash into software</title>
	<atom:link href="http://cwash.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://cwash.org</link>
	<description>+= construction + craftsmanship;</description>
	<pubDate>Wed, 03 Sep 2008 19:24:22 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>Tool Month</title>
		<link>http://cwash.org/2008/09/01/tool-month/</link>
		<comments>http://cwash.org/2008/09/01/tool-month/#comments</comments>
		<pubDate>Mon, 01 Sep 2008 13:29:27 +0000</pubDate>
		<dc:creator>Chris Wash</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://cwash.org/?p=10</guid>
		<description><![CDATA[If you&#8217;re a man, and you don&#8217;t love tools and gadgets, you&#8217;ve probably gone through your share of ridicule because of it.  This goes doubly for tech geeks that comprise the software industry; as Dave Platt explains, we seem to go out of our way to use even the most complicated and unweildy tools.  While [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re a man, and you don&#8217;t love tools and gadgets, you&#8217;ve probably gone through your share of ridicule because of it.  This goes doubly for tech geeks that comprise the software industry; as Dave Platt explains, we seem to go out of our way to use even the most <a title="Why Software Sucks" href="http://www.youtube.com/watch?v=JAOTTLQ0rlY">complicated and unweildy tools</a>.  While his point is more about how we should consider the interests of our users, it&#8217;s my opinion that the sign of a good craftsman and engineer is a marked proficiency with tools.  There is a great section in the pragmatic programmer that describes a master craftsman&#8217;s tools being extensions of the mind and body, under control at all times and working toward the same vision/goal.  I think another mark of a master is a breadth of knowledge, which is just as important as knowing how to properly use and maintain the tools in your toolbox.  A master should be cognizant of when a tool can be more of a hazard than a utility (think of cutting a sheet of paper with a chainsaw).</p>
<p>I&#8217;ve been doing my best to keep up with the latest tooling trends for Java development.  I think for the vast majority of people, there is a great one-stop resource out there: <a href="http://safari.oreilly.com/9780596527938" title="Safari Books Online: Java Power Tools">Java Power Tools</a>.  But any good &#8220;one-stop&#8221; book is not going to try to cover <em>everything</em>, and that&#8217;s what I&#8217;m going to try to do over the next few posts.  My goal is to scour <a href="http://delicious.com/nukeevry1">my del.icio.us</a> and some of the tidbits that I have laying around to highlight some of the more obscure or newer tools that didn&#8217;t make it into JPT, and in addition, some tools that should just be on your radar as a developer in general.  I&#8217;ll be bundling them into groups and shooting to release them in a few parts over the coming month.  Stay tuned!</p>
]]></content:encoded>
			<wfw:commentRss>http://cwash.org/2008/09/01/tool-month/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Weblogic 9.2 + Seam : Victory is Mine!</title>
		<link>http://cwash.org/2008/08/21/weblogic-92-seam-victory-is-mine/</link>
		<comments>http://cwash.org/2008/08/21/weblogic-92-seam-victory-is-mine/#comments</comments>
		<pubDate>Thu, 21 Aug 2008 11:45:38 +0000</pubDate>
		<dc:creator>Chris Wash</dc:creator>
		
		<category><![CDATA[JBoss Seam]]></category>

		<category><![CDATA[epic battle]]></category>

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

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

		<category><![CDATA[seam-gen]]></category>

		<category><![CDATA[weblogic 9]]></category>

		<guid isPermaLink="false">http://cwash.org/?p=24</guid>
		<description><![CDATA[What I learned getting a Seam-gen'd project running on WL9.]]></description>
			<content:encoded><![CDATA[<p>After fighting with WebLogic 9.2 for a while, I was able to get a seam-gen&#8217;d app running.</p>
<p>You&#8217;re relegated to using JPA/Hibernate because of an outstanding bug BEA and Sun seem to be both pointing fingers at each other over, but it&#8217;s not a big deal.  At least for now, all of the persistence in this app is going to be offloaded to services.</p>
<p>I&#8217;ll work on writing this up more formally, but here was a running list of issues I had to deal with.  If you need more information, let me know.  I apologize that this is kind of rough, but it&#8217;s better than nothing.</p>
<ol>
<li>Follow steps outlined in reference guide. (http://docs.jboss.com/seam/2.0.2.SP1/reference/en-US/html_single/#weblogic)</li>
<li>Change the build.xml&#8217;s jboss.home&#8217;s to bea.home&#8217;s, and redefine them like so:
<div>
<pre>&lt;property name="deploy.dir" value="${bea.domain.dir}/autodeploy" /&gt;
&lt;property name="jboss.deploy.dir" value="${jboss.home}/server/default/deploy" /&gt;</pre>
</div>
</li>
<li>Remove the library-ref from weblogic.xml (that you put in following the ref guide).</li>
<li>Remove the Namespace, Schema, and Version definitions for the web-app tag in web.xml - there&#8217;s a problem trying to add version 2.5&#8230; (https://jira.jboss.org/jira/browse/JBSEAM-2247)</li>
<li>Remove JSF/MyFaces deployments from WL domain if there are any (JSF 1.1 libraries conflicting with 1.2)</li>
<li>Add jsf-api.jar, jsf-impl.jar, commons-collections.jar, persistence-api.jar, el-api.jar, el-ri.jar (needed to pull out of seam fisheye) to deployed-jars.list.  You should be seeing Seam trying to start up at this point, IOW, you&#8217;re in &#8220;whack-a-jar&#8221; mode.</li>
</ol>
<p>One other funky thing &#8212; and I&#8217;m not sure what error exactly was causing this (probably related to the interceptors and JSF problems causing the deployment to suspend) but WL was causing some locks to occur that I had to clear out of my domain/server/tmp/* and basically &#8220;clean&#8221; everything out.  It was quite annoying, but things seem to be better now.</p>
<p><a href="http://cwash.org/wp-content/uploads/2008/08/seamgen-on-weblogic.jpg"><img class="aligncenter size-full wp-image-26" title="seamgen-on-weblogic" src="http://cwash.org/wp-content/uploads/2008/08/seamgen-on-weblogic.jpg" alt="" width="500" height="250" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://cwash.org/2008/08/21/weblogic-92-seam-victory-is-mine/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How I Escape the &#8220;Reuse Trap&#8221;</title>
		<link>http://cwash.org/2008/08/02/how-i-escape-the-reuse-trap/</link>
		<comments>http://cwash.org/2008/08/02/how-i-escape-the-reuse-trap/#comments</comments>
		<pubDate>Sat, 02 Aug 2008 16:25:57 +0000</pubDate>
		<dc:creator>Chris Wash</dc:creator>
		
		<category><![CDATA[Software Engineering]]></category>

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

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

		<category><![CDATA[reuse trap]]></category>

		<category><![CDATA[software development]]></category>

		<guid isPermaLink="false">http://cwash.org/?p=22</guid>
		<description><![CDATA[While I was reading "The Reuse Trap In Software Design" I found myself thinking,"Me too! Me too!" like a giddy kid on the playground that's found a new pal with a mutual interest in "pet snakes and/or tarantulas."  As with many of the problems Basil writes about in his blog, I experienced the same problem, investigated it and found the same root causes, and came to many of the same conclusions as those outlined.  My preferred technique for getting out of this quagmire is a little bit different than Basil's and I describe it in this article.]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve checked out my blogroll, you&#8217;ll notice I have a link to <a title="Professional Software Development" href="http://www.basilv.com/psd/" target="_blank">Basil Vandegriend&#8217;s &#8220;Professional Software Development&#8221;</a> blog.  I like a lot of the articles he has written and to a large extent the subject matter I envision for this blog frequently crisscrosses with Basil&#8217;s.</p>
<p>While I was reading &#8220;<a title="The Reuse Trap In Software Design" href="http://www.basilv.com/psd/blog/2006/the-reuse-trap-in-software-design#comment-58049" target="_blank">The Reuse Trap In Software Design</a>&#8221; I found myself thinking,&#8221;Me too! Me too!&#8221; like a giddy kid on the playground that&#8217;s found a new pal with a mutual interest in &#8220;pet snakes and/or tarantulas.&#8221;  As with many of the problems Basil writes about in his blog, I experienced the same problem, investigated it and found the same root causes, and came to many of the same conclusions as those outlined.  He describes the &#8220;reuse trap&#8221; as:</p>
<blockquote><p>&#8230;[A] term I coined to describe the situation when one becomes stuck trying to design new functionality while simultaneously attempting to reuse existing code that needs some modifications.</p></blockquote>
<p>He then goes on to describe why it&#8217;s a tough problem for n00bs and outlines a strategy he uses to get out of the trap–one that&#8217;s best described as a two-step process: <em>copy-paste to reuse/refactoring to remove duplication</em>.  I encourage you to read his article if you&#8217;re not familiar with the terms, or how this strategy can solve the problem described above.</p>
<p>My preferred technique for mitigating the problems involved isn&#8217;t <em>copy-paste reuse/refactoring</em>; it&#8217;s stubbing the calls to the code-to-be-reused (C2BR) that needs modification.  If I can fake out the behavior I need, it lets me focus on the nature of the dependency that exists between the two objects/components.  When I go to modify the C2BR, my inputs and outputs (or other consequences that occur as a result of a call to the C2BR) translate directly into a test that I can use to drive the changes I make to that code.  It also ensures that the coupling that exists between the objects is loose and legit.</p>
<p>The only thing to watch out for is that care must be taken to then remove the (small) duplication of the stubbed out inputs/outputs and actually wire the two pieces together when finished with the reused code.  I usually do that by throwing a TODO:WIRE marker in when I stub something.</p>
<p>I&#8217;ve found this is the approach I take more often, though I do take the <em>copy-paste reuse/refactoring</em> route from time to time.  This <strong><em>stub/rewire</em></strong> approach is a bit more advanced, but it&#8217;s how I envisioned solving the &#8220;reuse trap&#8221; when, as Basil puts it, &#8220;I became aware of it&#8221; and all that it entailed.</p>
<p>Do you ever come across this problem?  How do you get out of this &#8220;trap&#8221; or avoid being caught up in it in the first place?</p>
]]></content:encoded>
			<wfw:commentRss>http://cwash.org/2008/08/02/how-i-escape-the-reuse-trap/feed/</wfw:commentRss>
		</item>
		<item>
		<title>New Apple Wireless Keyboard</title>
		<link>http://cwash.org/2008/08/01/new-apple-wireless-keyboard/</link>
		<comments>http://cwash.org/2008/08/01/new-apple-wireless-keyboard/#comments</comments>
		<pubDate>Fri, 01 Aug 2008 18:55:02 +0000</pubDate>
		<dc:creator>Chris Wash</dc:creator>
		
		<category><![CDATA[Meta/Blog]]></category>

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

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

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

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

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

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

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

		<guid isPermaLink="false">http://cwash.org/?p=20</guid>
		<description><![CDATA[My take on the latest Apple Wireless Keyboard.]]></description>
			<content:encoded><![CDATA[<p>On <a title="ongoing - On Keyboards" href="http://www.tbray.org/ongoing/When/200x/2008/07/22/On-Keyboards" target="_blank">Tim Bray&#8217;s recommendation</a>, I just picked up a new Apple Wireless Keyboard:</p>
<p><a href="http://cwash.org/wp-content/uploads/2008/08/wak.png"><img class="aligncenter size-full wp-image-21" title="Apple Wireless Keyboard" src="http://cwash.org/wp-content/uploads/2008/08/wak.png" alt="" width="446" height="308" /></a></p>
<p>So far, it seems like a good choice.  As mentioned in Tim&#8217;s post, I notice my typing speed has dramatically increased immediately, when compared to the built in keyboard, or the stock Dell keyboards I&#8217;ve been typing on when not at my Mac recently.</p>
<p>I didn&#8217;t think the num pad warranted the extra space it&#8217;ll take up when I carry it around with me.  The super big command key doesn&#8217;t concern me quite as much, because I&#8217;ve gotten used to slipping my left thumb down to hit it from hovering over the spacebar, and it&#8217;s easier/more natural to do that on this keyboard compared to the one built into the MBP.</p>
<p>And this all goes without saying that the wireless features are a big plus.  Whenever you sit down to do something, having to plug in an extra wire is nothing short of a pain in the ass (not to mention taking up valuable port space on my precious laptop).</p>
<p>So far I&#8217;m pretty happy with the purchase.  If my opinion changes, I&#8217;ll let you know, but the spot judgement is that it&#8217;s exactly what I was expecting.</p>
]]></content:encoded>
			<wfw:commentRss>http://cwash.org/2008/08/01/new-apple-wireless-keyboard/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Help the Good Guys</title>
		<link>http://cwash.org/2008/07/31/help-the-good-guys/</link>
		<comments>http://cwash.org/2008/07/31/help-the-good-guys/#comments</comments>
		<pubDate>Thu, 31 Jul 2008 19:22:18 +0000</pubDate>
		<dc:creator>Chris Wash</dc:creator>
		
		<category><![CDATA[Meta/Blog]]></category>

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

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

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

		<guid isPermaLink="false">http://cwash.org/?p=19</guid>
		<description><![CDATA[I think it's important to support and give back to products and efforts that are high quality and enhance your productivity, happiness, or everyday life.  A List Apart, a web published magazine "for people who make websites" was the first feed I remember adding to my feed reader.  It definitely falls into this "need to give back" category for me. ]]></description>
			<content:encoded><![CDATA[<p>I think it&#8217;s important to support and give back to products and efforts that are high quality and enhance your productivity, happiness, or everyday life.  <a title="A List Apart" href="http://alistapart.com">A List Apart</a>, a web published magazine &#8220;for people who make websites&#8221; was the first feed I remember adding to my feed reader.  It definitely falls into this &#8220;need to give back&#8221; category for me.  Their articles have a web design/development slant, and are written in a consistent, succinct, repeatable fashion.  It&#8217;s a successful site, and I applaud its efforts.</p>
<p>If you didn&#8217;t know about ALA, well now you know.  If you do know about them, give something back by participating in their <a title="A List Apart 2008 survey" href="http://alistapart.com/articles/survey2008" target="_blank">survey</a>.</p>
<p><a title="A List Apart 2008 survey" href="http://alistapart.com/articles/survey2008" target="_blank"><img class="aligncenter size-full wp-image-18" title="i-took-the-2008-survey" src="http://cwash.org/wp-content/uploads/2008/07/i-took-the-2008-survey.gif" alt="A List Apart 2008 Survey" width="180" height="46" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://cwash.org/2008/07/31/help-the-good-guys/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Pimp My Build</title>
		<link>http://cwash.org/2008/07/21/pimp-my-build/</link>
		<comments>http://cwash.org/2008/07/21/pimp-my-build/#comments</comments>
		<pubDate>Mon, 21 Jul 2008 18:18:50 +0000</pubDate>
		<dc:creator>Chris Wash</dc:creator>
		
		<category><![CDATA[Software Engineering]]></category>

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

		<category><![CDATA[build process]]></category>

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

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

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

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

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

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

		<guid isPermaLink="false">http://cwash.org/?p=5</guid>
		<description><![CDATA[In terms of the sheer number of moving parts, extravagance, and complexity, the build-tool landscape is one of bells and whistles that can be a little tough to stay on top of. There are a few important pieces of a robust and valuable build, no matter what tools you use to achieve it, and by breaking the build into modules or categories, we can make a little bit of sense out of the chaos.
]]></description>
			<content:encoded><![CDATA[<p>In terms of the sheer number of moving parts, extravagance, and complexity, the build-tool landscape is one of bells and whistles that can be a little tough to stay on top of. There are a few important pieces of a robust and valuable build, no matter what tools you use to achieve it, and by breaking the build into modules or categories, we can make a little bit of sense out of the chaos.</p>
<p>In our vast build-tool landscape, there tend to be some zealous cults out there, entrenched deeply in their own camps and unwilling to venture out to explore what the rest of the landscape has to offer.   Thus, there have been some religious-like differences of opinion about which build tools are better and why.  Sadly you run across these types of biases all too often, which only pollutes the landscape and makes it more difficult to wrap your head the most basic questions underlying all tools:</p>
<ul>
<li>What does it accomplish?</li>
<li>When is it (or isn&#8217;t it) right for the job?</li>
<li>How do I use it effectively and efficiently?</li>
</ul>
<p>With a pragmatic view, we can try to cut through a lot of the BS and figure out if a tool is worth its weight in:</p>
<ol>
<li> dependencies/design complexity.</li>
<li>ease of use/interface complexity.</li>
<li>architectural decisions/compromises that it brings to the table.</li>
</ol>
<p>Does the tool get us to the goal of a single button build/deploy?  If the answer is yes, I&#8217;ll welcome it with open arms.  Does it add me a form of feedback or some kind of statistic that could be a kind of gauge on a dashboard?  Then I may be interested in it, but it&#8217;s not nearly as vital.</p>
<p>Here&#8217;s an outline of what I typically look to include in a project&#8217;s build before I am satisfied:</p>
<ul>
<li>Compile - Obviously your build script would be for naught if you didn&#8217;t include this piece.  There&#8217;s also something to be said about some dynamic/interpreted languages (that run on the JVM) taking the hit on this step and producing compiled versions.  The argument is akin to compiling your JSPs back in the day.</li>
<li>Unit test suite - Another one of those no-brainers!  You&#8217;ll obviously want to integrate your ability to run a single test or test suite from a build tool quickly and easily.</li>
<li>Test reports - Test reports are an important way of visualizing the health of your project and are usually the first place you&#8217;ll go when you see something wrong.  A must have.</li>
<li>Transitive dependency management - This is one of those sticky subjects that people like to argue about religiously.  Really the important thing to note here is that a crucial part of keeping your build clean and manageable is figuring out how to represent and resolve <em>transitive</em> dependencies, or second-level dependencies.  If your code directly depends on a library, odds are that library has its own run-time dependencies that need to be satisified in order for it to work properly.  Since managing the different versions of many different libraries can become tough when you start to look at different &#8220;stacks&#8221; of software, many people advocate having a tool help you resolve these dependencies so it&#8217;s not as daunting a task to get the entire stack to work again when you need to upgrade a single library.  Maven and Ivy solve this problem by introducing repositories that will house and dynamically resolve these versioning issues, in much the same manner as yum or apt-get does in the Linux world.  A lot of newbs will make the mistake of thinking this type of functionality will let them turn off their brain when it comes to think about their project&#8217;s dependencies.  They will be sorely mistaken!  The point of these to make resolving conflicts in transitive dependencies easier, they do not replace your brain, nor your obligation to know the dependencies in your project and how they fit together!</li>
<li>Utility ant tasks - the daunting part of learning how to write good builds has a bit to do with how much you know about the ant task landscape.  Nearly all libraries have tools that plug into ant, but which ones do you really need to know about?  I&#8217;ve found a few are quite powerful, particularly <a title="Replace Task" href="http://ant.apache.org/manual/CoreTasks/replace.html" target="_blank">replace</a>, <a title="Uptodate Task" href="http://ant.apache.org/manual/CoreTasks/uptodate.html">uptodate</a>, <a title="CvsTagDiff task" href="http://ant.apache.org/manual/CoreTasks/cvstagdiff.html" target="_blank">cvstagdiff</a> (and corresponding svn&#8217;s), <a title="XMLTask" href="http://www.oopsconsultancy.com/software/xmltask/" target="_blank">xmltask</a> and <a title="dbdeploy" href="http://dbdeploy.com/" target="_blank">dbdeploy</a>.  I think these tools should be looked at when you are trying to figure out how to accomplish something specific, and for that reason, they&#8217;re a bit more like &#8220;bells and whistles&#8221; than anything else.  The same goes for the next category, which arguably doesn&#8217;t even need to live in your build (but if you&#8217;re a team player, it&#8217;s a definite nice to have):</li>
<li>Static analysis - There have been a barage of slick static-analysis tools that have entered the Java landscape recently.  A few are <a title="FindBugs" href="http://findbugs.sourceforge.net/" target="_blank">FindBugs</a>, <a title="PMD" href="http://pmd.sourceforge.net/" target="_blank">PMD</a>, <a title="CheckStyle" href="http://checkstyle.sourceforge.net/" target="_blank">CheckStyle</a>.  While most of these tools have plugins that integrate nicely into an IDE, it&#8217;s also helpful to have them plugged into your build, too.  Just to make sure everyone is following the rules.  A few others I&#8217;ve seen that focus on cyclomatic complexity, cohesion/coupling are <a title="Metrics" href="http://metrics.sourceforge.net/">Metrics</a> and <a title="JDepend" href="http://clarkware.com/software/JDepend.html" target="_blank">JDepend</a>.</li>
</ul>
<p>What build tools fit into your pimped out script?</p>
]]></content:encoded>
			<wfw:commentRss>http://cwash.org/2008/07/21/pimp-my-build/feed/</wfw:commentRss>
		</item>
		<item>
		<title>New Wave Logging</title>
		<link>http://cwash.org/2008/03/19/new-wave-logging/</link>
		<comments>http://cwash.org/2008/03/19/new-wave-logging/#comments</comments>
		<pubDate>Wed, 19 Mar 2008 19:34:39 +0000</pubDate>
		<dc:creator>Chris Wash</dc:creator>
		
		<category><![CDATA[JBoss Seam]]></category>

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

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

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

		<category><![CDATA[software development]]></category>

		<category><![CDATA[web beans]]></category>

		<guid isPermaLink="false">http://cwash.org/2008/03/19/new-wave-logging/</guid>
		<description><![CDATA[Tired of messy logging logic cluttering your code with a bunch of if/else statements?  Don't let logging cramp your style! The approach <a href="http://www.seamframework.org" title="JBoss Seam">Seam</a> takes to logging makes your code pretty again (and other things).  What does this mean for you?  No more "<em>code guards</em>"!

A nice byproduct of the genius of Seam's design is that many common problems can be solved by using <em>EL </em>as veritable swiss-army knife.  We'll look at this through a logging example specifically, though it's just one of many different innovative ways of solving problems using Java5 features and <a href="http://docs.jboss.com/seam/2.0.1.GA/reference/en/html_single/#elenhancements">EL</a> as a general approach.]]></description>
			<content:encoded><![CDATA[<p>Tired of messy logging logic cluttering your code with a bunch of if/else statements?  Don't let logging cramp your style! The approach <a href="http://www.seamframework.org" title="JBoss Seam">Seam</a> takes to logging makes your code pretty again (and other things).  What does this mean for you?  No more "<em>code guards</em>"!</p>
<p>A nice byproduct of the genius of Seam's design is that many common problems can be solved by using <em>EL </em>as veritable swiss-army knife.  We'll look at this through a logging example specifically, though it's just one of many different innovative ways of solving problems using Java5 features and <a href="http://docs.jboss.com/seam/2.0.1.GA/reference/en/html_single/#elenhancements">EL</a> as a general approach.</p>
<h3>WTF is a code guard?</h3>
<p>What goes without saying in most of the discussions regarding logging is that excessive logging can be the largest and most common performance bottleneck in code that meets its functional requirements.  Thus, logging APIs introduce the idea of log levels, to ease the burden of excessive logging.  Generally, log levels are a configuration setting on a per-environment basis.  Development environments will typically log most dependent code at the <em>info </em>level, and cut that up to the <em>debug</em> level for custom code or when things go awry with a piece of dependent code.  Testing environments typically log at <em>info</em> while production will often just log at the <em>warn</em> level.</p>
<p>While this is all well and good, we find that for a lot of the logging we do, we typically run across an ugly little flaw in this approach that's produced an equally ugly hack as a work-around.  Enter the <em>code guard</em>.  From the log4j docs:</p>
<blockquote><p>Code guards are typically used to guard code that only needs to execute in support of logging, that otherwise introduces undesirable runtime overhead in the general case (logging disabled). Examples are multiple parameters, or expressions (e.g. string + " more") for parameters. Use the guard methods of the form log.is&lt;Priority&gt;() to verify that logging should be performed, before incurring the overhead of the logging  method call. Yes, the logging methods will perform the same check, but only after resolving parameters.</p></blockquote>
<p>What's all this business about resolving parameters?  Let's look at an example:</p>
<div class="igBar"><span id="ljava-1"><a href="#" onclick="javascript:showPlainTxt('java-1'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite">
<div id="java-1">
<div class="java"><span style="color: #808080; font-style: italic;">// unguarded code</span><br />
log.<span style="color: #006600;">debug</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"FOO: "</span> + foo + <span style="color: #ff0000;">", BAR: "</span> + foo.<span style="color: #006600;">getBar</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</div>
</div>
<p></p>
<div class="igBar"><span id="ljava-2"><a href="#" onclick="javascript:showPlainTxt('java-2'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite">
<div id="java-2">
<div class="java"><span style="color: #808080; font-style: italic;">// guarded code</span><br />
<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>log.<span style="color: #006600;">isDebugEnabled</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
log.<span style="color: #006600;">debug</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"FOO: "</span> + foo + <span style="color: #ff0000;">", BAR: "</span> + foo.<span style="color: #006600;">getBar</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span></div>
</div>
</div>
<p></p>
<p>So, we need this cluttered if/else around only to ensure that our expressions (concats, usually) won't get resolved unless we actually want them to.  Why is there no other recourse?  The answer isn't surprising – it comes down to the way the API was designed.  All log4j logging methods take a single argument -- which made a lot of sense, I suppose when the powers that be first designed logging APIs. They soon realized that in order to use their API, one has to use an expression to resolve all parameters into a single argument prior to calling the method!  This is why a code guard is needed.</p>
<p>Java5 introduces a feature that allows for <a href="http://java.sun.com/j2se/1.5.0/docs/guide/language/varargs.html" title="Variable Length Arguments" target="_blank">varargs</a>, and taking advantage of this can help us with our ugly little logging problem, e.g.</p>
<div class="igBar"><span id="ljava-3"><a href="#" onclick="javascript:showPlainTxt('java-3'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite">
<div id="java-3">
<div class="java">log.<span style="color: #006600;">debug</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"FOO: #0, BAR: #1"</span>, foo, foo.<span style="color: #006600;">getBar</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</div>
</div>
<p></p>
<p>With this approach, our expressions won't get resolved until after we're in debug(), and we can let it do the dirty work inside the method.  The first thing that our logging method does is check to see if its level is valid, otherwise it'll fall out immediately.  Because the concatenation happens inside the log method, we don't need a code guard to protect us.</p>
<p>This is the approach that Seam takes to logging.  Seam's <a href="http://docs.jboss.com/seam/latest-2/api/org/jboss/seam/log/Log.html" title="Seam's Log Interface">Log</a> interface provides not only a solution that removes the need for code guards, it also allows you to use EL in your log messages (if you're trying to dive into a Seam component...) - e.g.</p>
<div class="igBar"><span id="ljava-4"><a href="#" onclick="javascript:showPlainTxt('java-4'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite">
<div id="java-4">
<div class="java">log.<span style="color: #006600;">debug</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"FOO: #{foo}, BAR: #{foo.bar}"</span><span style="color: #66cc66;">&#41;</span>;</div>
</div>
</div>
<p></p>
<p>Much better.  By and large, this is the way you do logging in Seam.  Because binding occurs late, you never really run into the problem where you need to even think about using something like a "code guard."  Code what you're supposed to; not noise! <strong>This is just one of many novel ways to use EL in Seam</strong>, and why it really deserves a look as a way to write better code, faster and as a far more productive platform for Java programmers (fed up with JavaSE/EE 1.4) than Rails/Grails.</p>
<p>See the <a href="http://in.relation.to/Bloggers/TheWebBeansManifesto" target="_blank" title="Web Beans Manifesto">Web Beans Manifesto</a> for much more on this approach.</p>
]]></content:encoded>
			<wfw:commentRss>http://cwash.org/2008/03/19/new-wave-logging/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Continuous Integration Dissected</title>
		<link>http://cwash.org/2008/03/13/continuous-integration-dissected/</link>
		<comments>http://cwash.org/2008/03/13/continuous-integration-dissected/#comments</comments>
		<pubDate>Thu, 13 Mar 2008 16:29:06 +0000</pubDate>
		<dc:creator>Chris Wash</dc:creator>
		
		<category><![CDATA[Software Engineering]]></category>

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

		<category><![CDATA[build process]]></category>

		<category><![CDATA[continuous integration]]></category>

		<category><![CDATA[development practices]]></category>

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

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

		<guid isPermaLink="false">http://cwash.org/2008/03/13/continuous-integration-dissected/</guid>
		<description><![CDATA[A lot gets written about Continuous Integration, particularly on which is the best visual cue to let you know your build is broken or that a test is failing – lava lamps, Beta Brights, <a href="http://www.thinkgeek.com/gadgets/electronic/5da2/" title="This is probably not the last link to ThinkGeek from me">Ambient Orbs</a>, and some even suggest traffic lights. But aside from this extraneous (at least to business) nerd-banter, a lot of what I find written about the actual topic of CI is fluffy, ivory tower, or pie-in-the-sky jibber-jabber that leaves out important parts of the big picture or confuses people more than it helps.  In hopes of clearing up confusion on what exactly CI is and how it's <em>supposed</em> to work, I'm ripping out a description that I wrote for a client proposal recently (so my apologizes for the dry-tone).  I hope sheds some light on the true nature of CI, why it's important and how to implement it from a birds-eye point of view.
<p style="text-align: center"><img src="http://techepics.com/files/mythbusters_exploading_lava.jpg" alt="Lava Lamps" height="175" hspace="10" width="195" /></p>]]></description>
			<content:encoded><![CDATA[<h3>Setting the Record Straight</h3>
<p>A lot gets written about Continuous Integration, particularly on which is the best visual cue to let you know your build is broken or that a test is failing – lava lamps, Beta Brights, <a href="http://www.thinkgeek.com/gadgets/electronic/5da2/" title="This is probably not the last link to ThinkGeek from me">Ambient Orbs</a>, and some even suggest traffic lights. But aside from this extraneous (at least to business) nerd-banter, a lot of what I find written about the actual topic of CI is fluffy, ivory tower, or pie-in-the-sky jibber-jabber that leaves out important parts of the big picture or confuses people more than it helps.  In hopes of clearing up confusion on what exactly CI is and how it's <em>supposed</em> to work, I'm ripping out a description that I wrote for a client proposal recently (so my apologizes for the dry-tone).  I hope sheds some light on the true nature of CI, why it's important and how to implement it from a birds-eye point of view.</p>
<p style="text-align: center"><img src="http://techepics.com/files/mythbusters_exploading_lava.jpg" alt="Lava Lamps" height="350" hspace="10" width="390" /></p>
<h3>Continuous Integration Dissected</h3>
<p>Any large scale development project needs an automated, repeatable build process.  Following best practices while developing a build process properly separates environment-specific configuration concerns from the codebase.  This allows new environments to be created quickly and easily by simply overriding any environment-specific configuration values when first executing the build process.  Whatever build tool is being used, builds should share a common, consistent process and interface.  A consistent, repeatable build will know all of its dependencies and the goal is to be able to build any given module anywhere, independently, at any time.</p>
<p>Automated, repeatable build processes typically begin by obtaining dependencies (which can be specified using a dependency management tool) and a specific working-copy of the codebase ("checking out") from a SCM system like CVS or Subversion.  It is important to note that this codebase includes any code that is responsible for performing automated testing in addition to source code and configuration (and possibly other source-like artifacts).</p>
<p>Once the checkout has completed, the process will compile code and run automated unit test suites for each module in the system.  At this point, all automated unit tests should pass, and custom development can begin.  Any changes to code must be adequately covered by unit tests (either by changing existing tests or creating new ones), must fully compile without any errors and pass all automated unit test suites before being committed to the repository.  The practice of always keeping the code committed to the SCM repository in this state (no compilation or unit test errors) is known as Continuous Integration and ensures that new development is safe to proceed at any point without fear of integration errors.</p>
<p>Subversion (and CVS) support concurrent development by following a Copy-Edit-Merge paradigm; any contention over files is usually caught when a developer tries to commit their changes and notices the underlying files have changed since they obtained their copy.  In many cases, Subversion is capable of performing a merge automatically, if there was no contention over the same piece of a file.  Sometimes, however, a manual merge will be required.  Merging becomes more painful as the number of differences in the conflicting files increase.  A good rule of thumb is that every developer should commit their changes at least daily.</p>
<p>Designating a single machine as a Continuous Integration (CI) environment provides many added benefits to a large scale development project.  There are many operations which are good candidates to have run "continuously" but quite often are too expensive for developers to perform before every commit.  Examples include executing automated in-browser system tests (which, if maintained over multiple releases, can serve as a "mini" regression test suite), performance tests/profiling, producing test metrics, generating documentation, etc.  CI servers are an ideal place to schedule these processes to occur in an automated fashion.</p>
]]></content:encoded>
			<wfw:commentRss>http://cwash.org/2008/03/13/continuous-integration-dissected/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Bugs, Detectives, and Test Automation</title>
		<link>http://cwash.org/2008/03/11/bugs-detectives-and-test-automation/</link>
		<comments>http://cwash.org/2008/03/11/bugs-detectives-and-test-automation/#comments</comments>
		<pubDate>Tue, 11 Mar 2008 21:08:33 +0000</pubDate>
		<dc:creator>Chris Wash</dc:creator>
		
		<category><![CDATA[Software Engineering]]></category>

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

		<category><![CDATA[bug tracking]]></category>

		<category><![CDATA[development practices]]></category>

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

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

		<guid isPermaLink="false">http://cwash.org/2008/03/11/bugs-detectives-and-test-automation/</guid>
		<description><![CDATA[[Y]ou might suppose going to the trouble of creating automated tests, simply for your own devices, might be a bit overkill. As it turns out, it is worth it, and it's going to save you a lot of time in the long run.]]></description>
			<content:encoded><![CDATA[<p>You've done a thorough code review with your team and your code has come out with a few nice improvements.  Good.  You know that many a trustworthy source have speculated code reviews find as many as two times the number of defects that testing does. So you might suppose going to the trouble of creating automated tests, simply for your own devices, might be a bit overkill. As it turns out, it <em>is </em>worth it, and it's going to save you a lot of time in the long run.  Why is it so valuable?</p>
<p><span id="more-7"></span></p>
<p>Indulge me in a brief aside...  I saw Full Metal Jacket recently on cable for the up-teenth time; the first act of the film, the part that is set on Paris Island, is hard for me to flip away from. I usually end up catching at least the first quarter of the movie.  If you've seen it, you'll probably remember the part where the main characters recite, as new recruits, the Marine Corps prayer – it ends with "Without me, my rifle is useless; without my rifle, I am useless."  I think the prayer metaphorically makes sense if developers were reciting it and replaced the rifles with their automated tests.</p>
<p>To figure out why, let's answer the burning questions that first come to mind:</p>
<h3>Why should a developer care about doing their <em>own </em>testing?</h3>
<ol>
<li>It alerts you of problems (duh).</li>
<li>You'll have a check in place in case a bug ever <a href="http://www.youtube.com/watch?v=MCjskH74mVU" title="Fly REZ PLZ">comes back to life</a>.</li>
<li>It gives you the opportunity to fix things before anyone else finds out about them.</li>
<li>It's the best way to demonstrate that your code meets its requirements!</li>
</ol>
<h3>Why don't you want testers (or worse, end users) to find your bugs?</h3>
<p>First of all, let's be honest, this is an ideal to strive toward, even though actually achieving 100% test coverage and catching every possible bug is a definite pipe-dream.  But we have to keep in mind that bugs discovered by people other than a developer cause a lot of speculation, confusion, and in general, overhead work for everyone – time that could be better spent doing more productive things.  We'd like nothing better than to hand testers (and ultimately users) squeaky-clean code.  What happens if we don't? (and you won't!)</p>
<p>Imagine taking a class of third graders outside to find an insect in the "wild" and learn about (not burn) it with a magnifying glass. You're even able to get everyone to concentrate long enough to take a peek at a would-be critter. The first candidate you find turns out to be a piece of bark that looks like a beetle. As you're searching for another, two of your students get in a fight over claim to a partially decomposed boot they find. Another gets a nose bleed. When you finally manage to find another potential insect, you pass it over, mistaking the critter for a leaf. Little do you know it is actually a very well camouflaged member of the family <a href="http://en.wikipedia.org/wiki/Phylliidae" title="Phylliidae">Phyllidae</a>. <img src="http://upload.wikimedia.org/wikipedia/commons/1/12/LeafInsect.jpg" alt="A Leafy-looking bug" align="right" height="284" hspace="10" width="213" />By this time a child has fallen face first into a mud puddle and another has peed in his pants (which, one would think, should start to attract some insects).</p>
<p>Imagine that you do manage to find an insect in the wild; how would you get the whole class to observe it properly? There's just one magnifying glass. The moment you get it under the glass, it darts away. It's a struggle to keep track of. Not everyone is going to have a good viewing angle. If it disappears, then it might just as well be dead to you (did you hear that tree fall in the woods?).</p>
<p>Enough already with the horrible analogy? Okay, okay. The comparison of users to third graders in our thought experiment was purely coincidental – but you get the point. Having a group of people focus on a moving bug in "the wild" is tough! It'd be much easier to bring a captured critter into a controlled class environment to observe - our analog of a bug that we have caught with nifty our automated test net.</p>
<h3>Bug Detective?</h3>
<p>Given the fact that a tester's job is to find defects, odds are sometimes you'll get a defect report filed that looks like it's written in cuneiform and requires a wizard's hat, cauldron and lizard eyeballs to reproduce it. Sometimes<em> </em> a tester might not be giving you a legit bug – <em>sometimes</em>. There are a few scenarios that come to mind:</p>
<ol>
<li>A requirement is incomplete, misunderstood, miscommunicated or changed.</li>
<li>An external system was down.</li>
<li>An admin fat fingered something.</li>
</ol>
<p>This comes with the territory and you're just going to have to suck it up. You're ultimately the gumshoe on the case.  A good way to think of it is that testers and users are like the police of our system – they're responsible for being the first on the scene, drawing chalk outlines, "booking" the suspects we arrest, etc.   What the tester is explaining is probably going to confuse you at least a few times before it makes sense. If you have good testing support, this might not be that painful.  But you could have the Super Troopers on the case, <img src="http://upload.wikimedia.org/wikipedia/en/thumb/5/5a/2002_super_troopers_0001.jpg/800px-2002_super_troopers_0001.jpg" alt="The Super Troopers" align="left" height="200" hspace="10" width="300" />and each clue that comes in is going to waste more and more of your time. And heaven forbid an end user finds this problem, and then tries to communicate this to a support rep – your job then becomes ten times harder because you have to decode 2-3 levels of miscommunication that's occurred. Sometimes no good comes of all this, sometimes you find and squash a bug.  In cases where you don't know what to do, write some tests – ask what the outcome should be, let the answers create more questions and more tests.  And be sure to hold onto them!</p>
<p>Whatever the outcome, because good developers are lazy, we want more than anything else to prevent this from ever happening again. Worse case, you've spent a lot of time addressing something and should have at least a documented set of work you've done and decisions made. Make sure others know about this. Best case, you are able to add an automated test so you don't have to think about this ever again (or tell anyone about it - you'll know the moment when something goes wrong).</p>
<h3>Conclusion</h3>
<p>So let's recap –</p>
<ol>
<li>Bugs that slip to production are costly!</li>
<li>Automated tests help us exercise code before and after it goes into production.</li>
<li>If we work on a defect, our automated test net can help us catch a bug, or examine something that looks like a bug more closely.</li>
<li>Whenever we work on a bug (even if it's something that isn't truly a bug, but is being tracked as one) we should do our best to produce an automated test so we don't have to reinvestigate in the future.  A test beats an email- or source control commit-trail any day!</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://cwash.org/2008/03/11/bugs-detectives-and-test-automation/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Up And Running</title>
		<link>http://cwash.org/2008/02/14/up-and-running/</link>
		<comments>http://cwash.org/2008/02/14/up-and-running/#comments</comments>
		<pubDate>Thu, 14 Feb 2008 20:39:01 +0000</pubDate>
		<dc:creator>Chris Wash</dc:creator>
		
		<category><![CDATA[Meta/Blog]]></category>

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

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

		<guid isPermaLink="false">http://cwash.org/?p=3</guid>
		<description><![CDATA[Reinstalled WordPress.   I've been a little frustrated with other blog efforts that I've been roped into in the past few years and have decided that this is as good a place as any to just get stuff written down.  And there's really no good reason not to - so here'goes!
]]></description>
			<content:encoded><![CDATA[<p>Reinstalled WordPress.   I've been a little frustrated with other blog efforts that I've been roped into in the past few years and have decided that this is as good a place as any to just get stuff written down.  And there's really no good reason not to - so here'goes!</p>
]]></content:encoded>
			<wfw:commentRss>http://cwash.org/2008/02/14/up-and-running/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
