<?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>Manuel Aldana</title>
	<atom:link href="http://www.aldana-online.de/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.aldana-online.de</link>
	<description>Software Engineering Blog</description>
	<pubDate>Mon, 15 Feb 2010 23:43:33 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>Extending source-code syntax highlighting</title>
		<link>http://www.aldana-online.de/2009/12/13/extending-source-code-syntax-highlighting/</link>
		<comments>http://www.aldana-online.de/2009/12/13/extending-source-code-syntax-highlighting/#comments</comments>
		<pubDate>Sun, 13 Dec 2009 12:39:13 +0000</pubDate>
		<dc:creator>manuel aldana</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.aldana-online.de/?p=133</guid>
		<description><![CDATA[After all the decades of software development, and recently hyped trends (e.g. &#8220;programming in graphical diagrams&#8221;) plain text source code is still the most powerful way to build software systems. Regarding this a high degree of importance is readability and comprehension of source code. In fact you&#8217;re spending more time in reading as with writing [...]]]></description>
			<content:encoded><![CDATA[<p>After all the decades of software development, and recently hyped trends (e.g. &#8220;programming in graphical diagrams&#8221;) plain text source code is still the most powerful way to build software systems. Regarding this a high degree of importance is readability and comprehension of source code. In fact you&#8217;re spending more time in reading as with writing code. Apart from improving the structure of the code itself (the refactoring concept plays a big role here) syntax highlighting is also very important to get a quick overview. Following gives an example how and  why to tweak your editor defaults.<br />
<span id="more-133"></span></p>
<h3>IDE defaults</h3>
<p>Defaults from several IDEs or more simple text-editors are already giving big help, e.g. in showing keywords, instance fields or comments. Still in my view they can be tweaked, most of editors give options to extend things. Either they work with a graphical interface for changing settings (IDEs like IntelliJ, Eclipse etc.) or are working themselves with plain text highlighting configuration files (vim, krusader etc.). Your syntax highlighting toolbox contains text-decorations (like italic, underscored, bold) and coloring (foreground, background).<br />
For my tweaks I used my favorite IDE IntelliJ, which offers many syntax highlighting options. Just checkout your editor and see what is possible.</p>
<h3>Example BEFORE</h3>
<p>Following annoyed me on the default settings:</p>
<ul>
<li>Could not instantly see parameters and variables</li>
<li>No difference between local-vars and parameters</li>
<li>Non-javadoc comments were too grey. I write comments to explain the &#8216;Why&#8217; or a important block of a code statement. So comments should be better visible.</li>
<li>Todo comments were blue. Blue is a too &#8220;friendly&#8221; color to me, whereas looking at todos should wake me up!</li>
<li>Instance and static vars were colored the same though they have different semantics.</li>
<li>I tend to use more smaller methods as one monster method. The default highlighting does not separate between method declarations and calls.</li>
</ul>
<p>The BEFORE snippet:<br />
<img class="aligncenter" src="http://www.aldana-online.de/wp-content/uploads/2009/12/before.png" alt="before" /></p>
<h3>Example AFTER</h3>
<p>I changed settings to:</p>
<ul>
<li>Non-instance + static variables are blue now. Parameters should be handled with more care. (changing them side-effect the callee), so they are bold.</li>
<li>Static and instance vars have different colors now (pink vs. violet).</li>
<li>Comments have slight green background now.</li>
<li>Todo flags have the signal-color orange</li>
<li>Methods are underscored. Declarations are bold, calls are non-bold.</li>
</ul>
<p>The AFTER snippet:<br />
<img class="aligncenter" src="http://www.aldana-online.de/wp-content/uploads/2009/12/after.png" alt="after" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.aldana-online.de/2009/12/13/extending-source-code-syntax-highlighting/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Most favorite firefox addons/plugins</title>
		<link>http://www.aldana-online.de/2009/11/21/most-favorite-firefox-addons/</link>
		<comments>http://www.aldana-online.de/2009/11/21/most-favorite-firefox-addons/#comments</comments>
		<pubDate>Sat, 21 Nov 2009 12:03:13 +0000</pubDate>
		<dc:creator>manuel aldana</dc:creator>
		
		<category><![CDATA[Technologies/Tools]]></category>

		<guid isPermaLink="false">http://www.aldana-online.de/?p=132</guid>
		<description><![CDATA[One of firefox killer-features is the variety of add-ons. Following is an overview of the add-ons I use currently.

Vimperator
Vimperator is a real gem! Adds some vim (editor) feeling to the browser. Makes you faster, because nearly all mouse action can be supplemented with keyboard shortcuts. Also automates more complicated flows with macros. At start using [...]]]></description>
			<content:encoded><![CDATA[<p>One of firefox killer-features is the variety of add-ons. Following is an overview of the add-ons I use currently.<br />
<span id="more-132"></span></p>
<h3>Vimperator</h3>
<p><a href="https://addons.mozilla.org/en-US/firefox/addon/4891https://addons.mozilla.org/en-US/firefox/addon/4891" target="_blank">Vimperator</a> is a real gem! Adds some vim (editor) feeling to the browser. Makes you faster, because nearly all mouse action can be supplemented with keyboard shortcuts. Also automates more complicated flows with macros. At start using vimperator can be somewhat annoying because pressing some keys do unexpected things, but investing time to get used to it pays off definetely.</p>
<h3>Xmarks</h3>
<p><a href="https://addons.mozilla.org/en-US/firefox/addon/2410" target="_blank">Xmarks</a> saves your bookmarks to a server and makes synchronization possible between different machines. Very handy if you are working from different computers. Most likely it could be replaced by upcoming firefox 4 which offers this functionality in its core.</p>
<h3>Web Developer</h3>
<p><a href="http://addons.mozilla.org/en-US/firefox/addon/60" target="_blank">Web Developer</a> is a nice webdeveloper testing kit. Numerous things can be done like style/CSS testing, gathering meta-information of the page, handling cookies, finding broken images.</p>
<h3>Firebug</h3>
<p><a href="http://addons.mozilla.org/en-US/firefox/addon/1843" target="_blank">Firebug</a> is a perfect accompany to Webdeveloper for testing/analyzing websites. Offers JavaScript debugging, analyzing DOM tree, viewing CSS styleor watching HTTP calls and request/response contents. It is also plugin aware (see below).</p>
<h3>Firecookie</h3>
<p><a href="http://addons.mozilla.org/en-US/firefox/addon/6683" target="_blank">Firecookie</a> is an addon for firebug. Makes cookies handling (reading, deleting, editing) much easier as with Webdeveloper plugin.</p>
<h3>YSlow</h3>
<p><a href="http://addons.mozilla.org/en-US/firefox/addon/5369" target="_blank">YSlow</a> is an addon for firebug, which offers performance test for webapplications. Gives a good overview how your site performs and gives a summary in grade style (A-F). If it gives you bad grade, still question whether they are appropriate in your special case (e.g. YSlow moans about missing CDNs, but an usage of a CDN doesn&#8217;t always makes sense or you don&#8217;t have any control over certain included components).</p>
<h3>Live HTTP Headers</h3>
<p>Firebug offers good HTTP traffic tracking. But sometimes I also use <a href="http://addons.mozilla.org/en-US/firefox/addon/3829" target="_blank">Live HTTP Headers</a> because you can filter tracking HTTP calls by URL and content-type, for HTTP POST you can set your own defined payload.</p>
<h3>JSONView</h3>
<p>When testing webapps, instead of using curl sometimes it is handy to fire a HTTP request directly through firefox. If doing so by default firefox makes problems and prompts to save json (Content-type: application/json) as a file to instead of just displaying the content inside the browser window. <a href="http://addons.mozilla.org/en-US/firefox/addon/10869" target="_blank">JSONView</a> bypasses this and displays json content appropriately.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.aldana-online.de/2009/11/21/most-favorite-firefox-addons/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Parameterized test-methods with TestNG</title>
		<link>http://www.aldana-online.de/2009/04/19/parameterized-test-methods-with-testng/</link>
		<comments>http://www.aldana-online.de/2009/04/19/parameterized-test-methods-with-testng/#comments</comments>
		<pubDate>Sun, 19 Apr 2009 10:08:10 +0000</pubDate>
		<dc:creator>manuel aldana</dc:creator>
		
		<category><![CDATA[Continous Integration]]></category>

		<category><![CDATA[Software Engineering]]></category>

		<category><![CDATA[parameterized test case]]></category>

		<category><![CDATA[test-ng]]></category>

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

		<guid isPermaLink="false">http://www.aldana-online.de/?p=131</guid>
		<description><![CDATA[ TestNG offers many great features and is definitely more capable as JUnit to build a strong automated Test-Suite. When writing test-cases one important factor is the handling of test-data. With JUnit it is cumbersome to feed different test-data to the same test-code. TestNG solves this much better.

Let&#8217;s look at a very simple example. When [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://testng.org/doc/index.html" target="_blank"> TestNG</a> offers many great features and is definitely more capable as JUnit to build a strong automated Test-Suite. When writing test-cases one important factor is the handling of test-data. With JUnit it is cumbersome to feed different test-data to the same test-code. TestNG solves this much better.<br />
<span id="more-131"></span><br />
Let&#8217;s look at a very simple example. When trying to test an exception with JUnit 4 with different test-data I would need to write something like:</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="kw2">class</span> MyTest<span class="br0">&#123;</span></p>
<p>&nbsp; @Test<br />
&nbsp; <span class="kw2">public</span> <span class="kw4">void</span> throw_exception_if_wrong_input<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
&nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw2">try</span><br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw2">new</span> Foo<span class="br0">&#40;</span><span class="st0">&#8220;test-data1&#8243;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; fail<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#125;</span><span class="kw2">catch</span><span class="br0">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AIllegalArgumentException+java.sun.com&#038;bntl=1"><span class="kw3">IllegalArgumentException</span></a> iae<span class="br0">&#41;</span><span class="br0">&#123;</span><span class="br0">&#125;</span><br />
&nbsp; &nbsp;<br />
&nbsp; &nbsp; <span class="kw2">try</span><br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw2">new</span> Foo<span class="br0">&#40;</span><span class="st0">&#8220;test-data2&#8243;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; fail<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#125;</span><span class="kw2">catch</span><span class="br0">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AIllegalArgumentException+java.sun.com&#038;bntl=1"><span class="kw3">IllegalArgumentException</span></a> iae<span class="br0">&#41;</span><span class="br0">&#123;</span><span class="br0">&#125;</span><br />
&nbsp; &nbsp;<br />
&nbsp; &nbsp; <span class="kw2">try</span><br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw2">new</span> Foo<span class="br0">&#40;</span><span class="st0">&#8220;test-data3&#8243;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; fail<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#125;</span><span class="kw2">catch</span><span class="br0">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AIllegalArgumentException+java.sun.com&#038;bntl=1"><span class="kw3">IllegalArgumentException</span></a> iae<span class="br0">&#41;</span><span class="br0">&#123;</span><span class="br0">&#125;</span>&nbsp; &nbsp; <br />
&nbsp; <span class="br0">&#125;</span></p>
<p><span class="br0">&#125;</span></div>
</div>
<p>This code has essential problems:</p>
<ol>
<li> Because I want to avoid to write two more test-methods (essentialy the same production code is triggered), I am putting three test-cases into one test-method, which is bad practice. This is because test cases aren&#8217;t using the tearDown and setUp facilities and cannot guarantee isolation. That is also the reason that I could not use the excpectedException parameter inside the JUnit 4 @Test annotation. Alternative is to really use three test-methods, but code readability then suffers.
</li>
<li> Even though above example is very simplified (only <em>new Foo()</em> is called) the test-code is not expressive. Surely you could improve this by extracting method and giving a good name. But still it is a bit blurry, why we do so and that it is just for using different test-data.
</li>
</ol>
<h3>TestNG parameterized test-methods</h3>
<p>TestNG does it better and builds the &#8220;test-case differs only in test-data&#8221; situation into its framework. This is done by building a DataProvider and passing parameters to the test-method. This way code gets more expressive and each different test-data set is executed as an isolated test-case also. Here an example of the TestNG version of above test-cases (I followed the code centric way, you can also configure your DataProvider through an XML file):</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="kw2">class</span> MyTest<span class="br0">&#123;</span></p>
<p>&nbsp; @DataProvider<span class="br0">&#40;</span>name = <span class="st0">&#8220;wrong_input&#8221;</span><span class="br0">&#41;</span><br />
&nbsp; <span class="kw2">public</span> <a href="http://www.google.com/search?q=allinurl%3AObject+java.sun.com&#038;bntl=1"><span class="kw3">Object</span></a><span class="br0">&#91;</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="br0">&#93;</span> createData<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
&nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="co1">//2 dimensions</span><br />
&nbsp; &nbsp; <span class="co1">// x: data-set for one test-case</span><br />
&nbsp; &nbsp; <span class="co1">// y: set of parameters (test-method can contain multiple parameters)</span><br />
&nbsp; &nbsp; <span class="kw2">return</span> <span class="kw2">new</span> <a href="http://www.google.com/search?q=allinurl%3AObject+java.sun.com&#038;bntl=1"><span class="kw3">Object</span></a><span class="br0">&#91;</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="br0">&#93;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><span class="st0">&#8220;test-data-1&#8243;</span><span class="br0">&#125;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><span class="st0">&#8220;test-data-2&#8243;</span><span class="br0">&#125;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><span class="st0">&#8220;test-data-3&#8243;</span><span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span>;<br />
&nbsp;<span class="br0">&#125;</span></p>
<p>&nbsp;@Test<span class="br0">&#40;</span>expectedExceptions = <a href="http://www.google.com/search?q=allinurl%3AIllegalArgumentException+java.sun.com&#038;bntl=1"><span class="kw3">IllegalArgumentException</span></a>.<span class="kw2">class</span>, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dataProvider = <span class="st0">&#8220;wrong_input&#8221;</span><span class="br0">&#41;</span><br />
&nbsp;<span class="kw2">public</span> <span class="kw4">void</span> throw_exception_if_bad_input<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> input<span class="br0">&#41;</span><br />
&nbsp;<span class="br0">&#123;</span><br />
&nbsp; &nbsp;<span class="kw2">new</span> Foo<span class="br0">&#40;</span>input<span class="br0">&#41;</span><br />
&nbsp;<span class="br0">&#125;</span><br />
&nbsp;<br />
<span class="br0">&#125;</span></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.aldana-online.de/2009/04/19/parameterized-test-methods-with-testng/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Reasons NOT to use ClearCase</title>
		<link>http://www.aldana-online.de/2009/03/19/reasons-why-you-should-stay-away-from-clearcase/</link>
		<comments>http://www.aldana-online.de/2009/03/19/reasons-why-you-should-stay-away-from-clearcase/#comments</comments>
		<pubDate>Thu, 19 Mar 2009 00:20:18 +0000</pubDate>
		<dc:creator>manuel aldana</dc:creator>
		
		<category><![CDATA[Technologies/Tools]]></category>

		<category><![CDATA[clearcase not good]]></category>

		<guid isPermaLink="false">http://www.aldana-online.de/?p=128</guid>
		<description><![CDATA[After 3 years of working with ClearCase SCM tool I came to the point that you should not use it for developing software. Surely it has its moments: The branching and merging capabilities are good and the graphical version tree is nice. Also the concept of the config-spec, which is a kind of query-language for [...]]]></description>
			<content:encoded><![CDATA[<p>After 3 years of working with ClearCase SCM tool I came to the point that you should not use it for developing software. Surely it has its moments: The branching and merging capabilities are good and the graphical version tree is nice. Also the concept of the config-spec, which is a kind of query-language for an scm-configuration (the set of checked out artifacts) is powerful. But there also many shootout reasons, why it is bad.<br />
<span id="more-128"></span></p>
<h3>No atomic commits</h3>
<p>Once you checked in files it is very hard to revert to a certain state, because atomic commits aren&#8217;t supported. When checking in multiple files, each file gets a new revision (similar to CVS) and not the check-in itself. I think this is a crucial feature, because you hardly want revert single files but complete commit actions (which should map tasks). With ClearCase you can only revert to certain states by using Labels. In practice using ClearCase Labels for each check-in is overkill and thus not done.</p>
<h3>Crappy user interface</h3>
<p>The GUI of ClearCase Explorer is just a big joke. Horrible in usability and ugly looking. Different and often necessary functions aren&#8217;t provided (e.g. recursively checking in worked on artifacts). Command line tool cleartool used with cygwin is much better, but still some things aren&#8217;t available like recursively adding new files/folders to source control. I have to laugh my head off if I read a 50 lines of code long <a href=" http://www.ibm.com/developerworks/rational/library/4687.html#N10283" target="_blank">script</a> to workaround this.</p>
<h3>High administration efforts</h3>
<p>Administrating ClearCase beast is far from obvious or lightweight (in difference to other scm-systems like CVS, subversion or Git). Expect to put quite a few dedicated ClearCase experts to just keep it running.</p>
<h3>Horrible performance</h3>
<p>Nothing is worse as making your developers wait while interfacing with SCM-tool, it is like driving with hand brakes enabled. It slows down your brain and also your work. Getting fresh new files to your snapshot view takes around 30 minutes for 10K artifacts. An update (no artifacts were changed) for the same amount takes roughly 5 minutes. When experimenting a lot and jumping between different up-to-date views means a lot of waiting. It gets even worse, when you&#8217;re working on files and you want to check-in or update them. Check-out, check-in and adding to source control cycles take around 10-15 seconds which is obviously a nightmare. It gets very annoying when you&#8217;re refactoring renaming/moving types or methods (many files can be affected).</p>
<h3>Lack of support of distributed development</h3>
<p>Today software development is often a distributed thing (developers are spread around the world working on the same product/project). ClearCase definetely isn&#8217;t suitable for this,  because it is badly suited for offline work. Doing a check-out (action before you can edit  a file/folder) requires that you are network connected. Here you could use the hijack option but  this is rather a workaround as a feature (you basically just unlock the file on the filesystem). If your development sites are far away from your ClearCase server the check-in/check-out latency can even increase so dramatically that it is not usable at all. There are workarounds for that like using ClearCase Multisite (scm DB replica technology), but you have to pay extra for it and is not trivial to adminstrate.</p>
<h3>Git as alternative</h3>
<p>Though being a big fan+supporter of Open Source I am still willing to pay money for good software. But looking at IBM-monster ClearCase I wouldn&#8217;t invest my money here, it has all these discussed shortcomings, and further more IBM doesn&#8217;t seem to invest money to improve their product significantly. Recently I had a look a <a href="http://git-scm.com/" target="_blank">Git</a> scm which looks very good, especially for its branching+merging features, where ClearCase has its major strengths.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.aldana-online.de/2009/03/19/reasons-why-you-should-stay-away-from-clearcase/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Continous code improvement with IntelliJ scm-integration</title>
		<link>http://www.aldana-online.de/2009/02/18/continous-code-improvement-with-intellij/</link>
		<comments>http://www.aldana-online.de/2009/02/18/continous-code-improvement-with-intellij/#comments</comments>
		<pubDate>Wed, 18 Feb 2009 00:21:37 +0000</pubDate>
		<dc:creator>manuel aldana</dc:creator>
		
		<category><![CDATA[Software Engineering]]></category>

		<category><![CDATA[Technologies/Tools]]></category>

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

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

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

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

		<guid isPermaLink="false">http://www.aldana-online.de/?p=124</guid>
		<description><![CDATA[As software engineers we get overwhelmed by the masses of bad-quality source code we work with each day. At this stage improvement of all these source code artifacts is a never ending story. To tackle this problem IntelliJ IDE goes the step-by-step improvement approach, where it runs actions and includes its powerfull code inspections on [...]]]></description>
			<content:encoded><![CDATA[<p>As software engineers we get overwhelmed by the masses of bad-quality source code we work with each day. At this stage improvement of all these source code artifacts is a never ending story. To tackle this problem IntelliJ IDE goes the step-by-step improvement approach, where it runs actions and includes its powerfull code inspections on your changes you are about to propagate to source control repository.<br />
<span id="more-124"></span></p>
<h3>Code quality issue</h3>
<p>Code gets written and as it changes (in most cases) it rottens also. In many projects/products changing and adding functionality  means having a larger codebase. And the bigger it gets the more difficult it becomes to improve the overall code quality picture:</p>
<ul>
<li>Motivation of developers decreases to keep code clean. In the end code gets worse and worse, just have a look<br />
at the &#8216;Broken windows&#8217; chapter of &#8216;The Pragmatic Programmer&#8217; for details</li>
<li>Efforts to clean up increases, more code needs to be maintained. Even if we are highly motivated to write &#8216;good&#8217; code, it is often difficult to know where to start.</li>
</ul>
<h3>Solution: Improve what you change</h3>
<p>There are two ways to tackle the problem: Big Bang or continous code improval. With BigBang you dedicate armies of developers who touch code just for the sake of making the code &#8216;better&#8217;. This approach has its drawbacks: You still don&#8217;t know where to start, it is difficult to sell to the product owners (feature stop) and further more it gets really boring (ever tried to tidy up your flat for a whole week without doing anything else?). An approach which worked better for team members and me was to introduce a kind of continous code improvement. It is important not to say that we get from 10000 warnings to 0, but to make a commitment that the warnings never ever get higher and must decrease after constantly. Here you improve your code quality in parallel to feature development and you only improve what you change. This much better sells to the product owner, you even don&#8217;t need to mention it, because it is part of your daily effort and should be transparent for non-techies.<br />
Furhter more incremental work-items can be managed better and focusing on certain artifacts also reduces overall efforts. In my view the best &#8220;quality-gate&#8221; for such an improve-what-you-change workflow is the source control commit or checkin phase. You changed code and now you want to ensure that checked-in sources provide a certain code-quality level.</p>
<p>Source control dialog IntelliJ:</p>
<p style="text-align: center;"><img class="size-full wp-image-126" title="commit-phase" src="http://www.aldana-online.de/wp-content/uploads/2009/02/commit-phase.png" alt="" width="500" height="451" /></p>
<h3>IntelliJ approach to continous code quality improvement</h3>
<p>The real problem is the tooling support: Humans are very bad at automating repeatable tasks. For instance when I am using Eclipse IDE and commiting sources to for instance Subversion, I often forget to reformat source code, remove unused imports or am just overlooking bad code snippets. IntelliJ (tested on version 8.1) goes a much better way: It provides actions (auto-formatting, auto-importing) while commiting and besides that can run static code analysis. For this code analysis it includes the so called &#8216;Inspections&#8217;, which are numerous and sensible (<a href="http://www.jetbrains.com/idea/features/code_inspection.html" target="_blank"></a>). For some cases it even provides an automated correction of the code flaw and the corresponding code snippet (pressing Alt+Enter). All these actions and checks are performed for the items you are about to commit only. This way IntelliJ mandates the successful approach to improve what you change or touch.</p>
<p>Dialog to review inspections and inspection results after pressing &#8216;Review button&#8217; :<br />
<img class="alignnone size-medium wp-image-125 alignleft" style="float: left;" title="checkresult" src="http://www.aldana-online.de/wp-content/uploads/2009/02/checkresult.png" alt="" width="265" height="140" /><br />
<img class="size-full wp-image-127" title="resultdetails" src="http://www.aldana-online.de/wp-content/uploads/2009/02/resultdetails.png" alt="" width="500" height="285" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.aldana-online.de/2009/02/18/continous-code-improvement-with-intellij/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Getting rid of checked exceptions in Java</title>
		<link>http://www.aldana-online.de/2008/07/28/getting-rid-of-checked-exceptions-in-java/</link>
		<comments>http://www.aldana-online.de/2008/07/28/getting-rid-of-checked-exceptions-in-java/#comments</comments>
		<pubDate>Mon, 28 Jul 2008 00:34:35 +0000</pubDate>
		<dc:creator>manuel aldana</dc:creator>
		
		<category><![CDATA[Software Engineering]]></category>

		<guid isPermaLink="false">http://www.aldana-online.de/?p=123</guid>
		<description><![CDATA[Exception constructs in modern languages have replaced the way to map an error condition by a return value (like for instance in C). If used properly analyzation of error conditions and their handling can be performed very well. Never the less in Java, the so called checked exceptions are annoying since long (as a side [...]]]></description>
			<content:encoded><![CDATA[<p>Exception constructs in modern languages have replaced the way to map an error condition by a return value (like for instance in C). If used properly analyzation of error conditions and their handling can be performed very well. Never the less in Java, the so called checked exceptions are annoying since long (as a side note: C# seemed to have learned from this early language-design mistake because it supports unchecked exceptions only). This article discusses further why checked exceptions should be avoided.<br />
<span id="more-123"></span><br />
This topic was already <a href="http://www.mindview.net/Etc/Discussions/CheckedExceptions" target="_blank">discussed</a> by clever Bruce Eckel, who is also thinking that checked exceptions aren&#8217;t such a good idea. To his reasoning one thing I would like to add is the &#8220;blurry assumption of api-interface&#8221; problem.</p>
<h3>Anticipation of incoming dependencies not possible</h3>
<p>Officially <a href="http://java.sun.com/docs/books/tutorial/essential/exceptions/runtime.html">Sun mentions</a> that checked exceptions should be used in case of &#8220;expected&#8221; exceptions, where clients still could react. In contrast unchecked exception should be used if programming erros occur, where a reaction is hardly possible (e.g. NullPointerException,  AssertionError).</p>
<p>In case of checked exception client code can decide whether to react to it directly (try/catch) or to delegate and pass it in the throws clause. In practice many checked exceptions aren&#8217;t interesting to client code, therefore you start to pass it to the throws clause. After a while spreading exceptions between different class-collaborations they are getting piled up and code-distraction is king and developers are constantly typing irrelevant code.</p>
<p>I&#8217;ve often seen code where developers got fed up with this pass-through of exceptions, workarounded this  with a bad exception handling coding style. So, in theory checked exceptions should increase code quality but in practice I perceived the opposite. This is bad, because a programming language design should help you to write good code and not constrain your work. Following workaround code snippets are quite common:</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="kw2">try</span><span class="br0">&#123;</span><br />
&nbsp; &#8230;<br />
<span class="br0">&#125;</span><span class="kw2">catch</span><span class="br0">&#40;</span>AnyCheckedException ace<span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; <span class="co1">//no handling code</span><br />
&nbsp; <span class="co1">//swallowed away nirvana exception</span><br />
<span class="br0">&#125;</span></div>
</div>
<p>Above is evil: Though exception should somehow be reported in lower area of method call stack, this try/catch just makes any error handling impossible. Such &#8220;nirvana&#8221; exceptions can make your life  really hard when locating defects.</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="kw2">try</span><span class="br0">&#123;</span><br />
&nbsp; &#8230;<br />
<span class="br0">&#125;</span><span class="kw2">catch</span><span class="br0">&#40;</span>AnyCheckedException ace<span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; <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;Error I don&#8217;t know what to do with. Got fed up with<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; throws clause in all my method declarations!&#8221;</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></div>
</div>
<p>Problem is that above newly thrown RuntimeException is too general and analyzation of certain error-conditions is hard. Often the causing checked exception isn&#8217;t even passed to the RuntimeException constructor so finding the root cause of a failure is also difficult.</p>
<p>To summarize: If client code cannot handle the exception, in practice checked exceptions aren&#8217;t passed to throws clause of method declaration. Indeed you can get really crazy if you need to pass the exception the whole method call-stack. Especially when doing bigger refactorings such millions of checked exceptions in the throws declarations are extremely annoying. Looking at this shortcoming developers often go for an improper exception handling. The difficulty of api-designers is that they cannot anticipate the exception-interpretation of incoming dependencies and thus the use of a checked exception can lead to bad exception handling code. They just don&#8217;t know, if a handling of an exception makes sense or not, see following examples:</p>
<h4><u>Example checked IOException</u></h4>
<p><strong>Trigger:</strong> IOException from java.io api gets thrown because a file under given pathname cannot be found.<br />
<strong>Handling appropriate:</strong> My client-code represents a file system manager, where I am searching for a file. The information &#8220;File not found&#8221; is directly relevant and file system manager could proceed to look in other directories.<br />
<strong>Handling not appropriate:</strong> I got a general app, where a property file should be loaded. Then the app should crash early/instantly, most likely I set a wrong path (Programming error).</p>
<h4><u>Example checked RemoteException</u></h4>
<p><strong>Trigger:</strong> RemoteException gets thrown, because network connection for RMI communication is broken.<br />
<strong>Handling appropriate:</strong> My client-code is a network monitoring tool and such information should be logged down for server downtime analyzation. Thus exception should be directly handled.<br />
<strong>Handling not appropriate:</strong> I got two application components which are communicating with RMI. The defect is a misconfiguration of the firewall. Application itself cannot react on this, it is a plain network setup defect.</p>
<p>Now Sun&#8217;s exception convention gets into problems: They told that Programming-Errors should always be mapped to unchecked exceptions&#8230; As shown above this does not work out, in some contexts the root cause of IOException is a Programming error (property-file loading) in some not (file-manager).</p>
<h3>Way out of checked exceptions</h3>
<p>Most likely Java standard won&#8217;t change this exception design-flaw, especially for backward compatibility reasons. But there is still a solution: When you are forced to handle checked exceptions constantly you can wrap them in custom unchecked exceptions (-&gt; extending an own custom exception hierachy from RuntimeException). This way other client code does not need to bother to look at non-interesting exception. The implication of mentioned points could also be that your api-design should only offer unchecked exceptions in method declarations.</p>
<p>Following this clients are not distracted by always doing this try/catch duet and code further more gets much better readable. Of course you should not just shove all checked exceptions directly into a RuntimeException (one of the workaround I explained above), you should be more concrete and build up a deeper exception type-hierachy to make further handling easier. Besides you should chain checked exception and pass it to the unchecked exception&#8217;s constructor to later find out root causes better.</p>
<p>Of course at one point such unchecked exceptions need to be handled at the outmost layer latest to make a proper report possible (e.g notifying monitoring/logging, sending back a user-friendly error HTML-message). You really don&#8217;t want to spill the whole stack-trace to a HTML or SOAP response or make your application to completely always shutdown.</p>
<h3>Conclusion</h3>
<p>Java introduced checked exceptions, which seemed to be a good idea in the first place to enforce clients to &#8220;have to know&#8221; about certain error conditions. But in practice developers do not pass &#8220;uninteresting&#8221; exceptions in throws clause, because code gets crowded and diffult to understand. They merely tend to workaround with inappropraite exception handling. Further more the view on exceptions, wheter they are worth the be catched or not, is context based and cannot be anticipated. To avoid this problem api-designers or client code generally should go for unchecked exception and a custom unchecked exception type-hierachy.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.aldana-online.de/2008/07/28/getting-rid-of-checked-exceptions-in-java/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Avoiding xUnit test-errors (false positives, false negatives)</title>
		<link>http://www.aldana-online.de/2008/06/16/xunit-test-errors-false-positives-false-negative/</link>
		<comments>http://www.aldana-online.de/2008/06/16/xunit-test-errors-false-positives-false-negative/#comments</comments>
		<pubDate>Mon, 16 Jun 2008 18:20:30 +0000</pubDate>
		<dc:creator>manuel aldana</dc:creator>
		
		<category><![CDATA[Continous Integration]]></category>

		<category><![CDATA[Software Engineering]]></category>

		<guid isPermaLink="false">http://www.aldana-online.de/?p=118</guid>
		<description><![CDATA[You are using unit-tests to ensure that production code works as defined or specified from the class-level view. This way you either get feedback that your implementation works as wanted (green-bar=success) or not (red-bar=fail). Unfortunately tests are also man-crafted work and can contain bugs.  Following article shows what kind of test-errors exist and what [...]]]></description>
			<content:encoded><![CDATA[<p>You are using unit-tests to ensure that production code works as defined or specified from the class-level view. This way you either get feedback that your implementation works as wanted (green-bar=success) or not (red-bar=fail). Unfortunately tests are also man-crafted work and can contain bugs.  Following article shows what kind of test-errors exist and what preventive actions can be done.<br />
 <span id="more-118"></span></p>
<h3>Annoyance of test-errors</h3>
<p>Test-errors are very annoying because your tests should be the impartial authority saying your production works or not. And if you cannot rely on them and they are constantly lying to you, you quickly get the opinion that tests don&#8217;t help you but merely slow down your work tasks. In fact I noticed that many developers new to unit-tests are gettings frustrated by test-errors and thus are stopping to write them. This way they lose the advantages of a good test-suite and Test Driven Development which is a shame. Test-errors can roughly occur in two forms: false negatives and false positives. </p>
<h4>False positive test</h4>
<p>A false positive test gives you a failure, though the feature is behaving alright. You change or create some code, make everything compile but the corresponding test gives you a failure. After debugging for a while you see that the test made wrong expectations about the feature so that your test is inconsistent with the specified behaviour.</p>
<p>Very simplified example:</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="kw2">public</span> <span class="kw4">static</span> <span class="kw4">int</span> sum<span class="br0">&#40;</span><span class="kw4">int</span> x, <span class="kw4">int</span> y<span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; <span class="kw2">return</span> x+y;<br />
<span class="br0">&#125;</span></p>
<p><span class="kw2">public</span> <span class="kw4">void</span> testSum<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; assertTrue<span class="br0">&#40;</span><span class="nu0">3</span>,sum<span class="br0">&#40;</span><span class="nu0">1</span>,<span class="nu0">1</span><span class="br0">&#41;</span><span class="br0">&#41;</span>; <span class="co1">//fails though class under test alright</span><br />
<span class="br0">&#125;</span></div>
</div>
<p>I experience false positive tests sometimes when using mock-frameworks (like <a href="http://www.easymock.org/">EasyMock</a> ), because when injecting mocks to class under test you expose some bits of implementation details to the test by recording behaviour to the mock. After changing implementation of class under test slightly, the calling of your mocks could change also. Without changing your mocks correspondly your test most likely will fail.</p>
<p>Another often occurring cause for a false positive is a wrong test setup, e.g. you could pass wrong or no instances at all to class under test, so it behaves different as expected from test case view. Example: You pass an implementation to class under test, which connects to a file-database and wants to read data. Database is not available and test fails. Here you made a test setup mistake: Actually you had to pass a  persistence stub, which returns appropriate values for the test.</p>
<p>Further more your design could be too tightly coupled, where your class under test has many dependencies to other classes. Thus many other instances are called indirectly and it is difficult to isolate you &#8220;real&#8221; test case. A change of dependent classes makes the test fail, though class under test itself did not change and is still behaving fine.</p>
<h4>False negative test</h4>
<p>A false negative test reports you a success message that everything is alright but in fact it is broken. In this case all your test expectations (=asserts) are fine, but production code in fact has got a bug. </p>
<p>Same simple example:</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="kw2">public</span> <span class="kw4">static</span> <span class="kw4">int</span> sum<span class="br0">&#40;</span><span class="kw4">int</span> x, <span class="kw4">int</span> y<span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; <span class="kw2">return</span> x+<span class="nu0">1</span>;&nbsp; <br />
<span class="br0">&#125;</span></p>
<p><span class="kw2">public</span> <span class="kw4">void</span> testSum<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; assertTrue<span class="br0">&#40;</span><span class="nu0">2</span>,sum<span class="br0">&#40;</span><span class="nu0">1</span>,<span class="nu0">1</span><span class="br0">&#41;</span><span class="br0">&#41;</span>; <span class="co1">//success though class under test has a bug</span><br />
<span class="br0">&#125;</span></div>
</div>
<p>What I see often in false negative tests, is that assert statements are formulated too weak and claim not enough from class under test. In many test cases you find a very non-saying assertNotNull(returnObject) and the properties of returnObject are not checked more detailed.</p>
<h4>Preference of test-error</h4>
<p>The lesser evil test-error are definitely the false positives. Here I get instantly notified that there IS a test-error. Looking at a false negative test I don&#8217;t get notified at all and the overall &#8216;good&#8217; feeling that I got tests in place is very deceptive. You interpret more quality to your production code than there is.</p>
<h3>What to do about test-errors</h3>
<p>Awareness of both test-error categories is a good first step, but how can you avoid test-errors generally?</p>
<h4>Suggestions to avoid false positives</h4>
<p>An obvious cause for a false positive can be your test assert statements, maybe they are just plain wrong, requirements have been changed and class under test has been adjusted respectively. To avoid such assert statement mistakes you should develop test driven: When a requirement has been changed first look if feature has a corresponding test case and adjust it. After that change your production code. This way you avoid specification inconsistencies inside your test cases.</p>
<p>When looking at your production code, maybe your design is too tightly coupled and your tests are covering just to many classes? With this you should consider to introduce dependency-injection to make passings of alternative test-implementations possible. Or maybe you got a monster method and thus &#8220;feature-isolation&#8221; is not possible either? Here you should consider to use extract refactorings (method, interface, class), to achieve isolation and loose coupling and make stub/mock injections possible.</p>
<h4>Suggestions to avoid false negatives</h4>
<p>Most likely your assert statements are too weak and you don&#8217;t use enough test-data. Consider to add asserts an invoke class under test with alternative input values. The assertNotNull(returnObject) assert is often a good start to check whether the returnObject has been initialized at all, but if so, more &#8220;stronger&#8221; asserts should follow. Always remember: Apart from your application throwing an unexpected Exception inside test-run your test case will only fail if one of your asserts will evaluate to false!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.aldana-online.de/2008/06/16/xunit-test-errors-false-positives-false-negative/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Considerations Eclipse (3.3.2) vs. IntelliJ IDEA (7.x)</title>
		<link>http://www.aldana-online.de/2008/05/21/eclipse-vs-intellij/</link>
		<comments>http://www.aldana-online.de/2008/05/21/eclipse-vs-intellij/#comments</comments>
		<pubDate>Wed, 21 May 2008 17:38:18 +0000</pubDate>
		<dc:creator>manuel aldana</dc:creator>
		
		<category><![CDATA[Software Engineering]]></category>

		<category><![CDATA[Technologies/Tools]]></category>

		<category><![CDATA[intellij best ide]]></category>

		<category><![CDATA[intellij vs. eclipse]]></category>

		<guid isPermaLink="false">http://www.aldana-online.de/2008/05/21/considerations-eclipse-332-vs-intellij-idea-7x/</guid>
		<description><![CDATA[To master frameworks (Spring, Hibernate, EJB, Struts etc.) and language-systems (Java, PHP, Groovy, C++) you need your &#8220;big&#8221; handy IDE tool which is used for many reasons: Inclusions of third party libs (dependency-management), trigger automatic compiles (if neccessary), automatic/safe refactorings, browsing code, debug, execute tests etc. (the list goes on forever). For that central IDE-tool [...]]]></description>
			<content:encoded><![CDATA[<p>To master frameworks (Spring, Hibernate, EJB, Struts etc.) and language-systems (Java, PHP, Groovy, C++) you need your &#8220;big&#8221; handy IDE tool which is used for many reasons: Inclusions of third party libs (dependency-management), trigger automatic compiles (if neccessary), automatic/safe refactorings, browsing code, debug, execute tests etc. (the list goes on forever). For that central IDE-tool you should try to use the best one on the market. A few months ago I was interested how my implementation and design work would &#8220;feel&#8221; with a different IDE, so as a long-time Eclipse user I gave IntelliJ a chance. Following article gives an overview of my impressions on trying out a different IDE. My reference IDEs had been <a href="http://www.eclipse.org/ ">Eclipse 3.3.2</a> and <a href="http://www.jetbrains.com/idea/ ">IntelliJ 7.0.3</a>.<br />
<span id="more-117"></span></p>
<h3>Download/Installation IntelliJ</h3>
<p>Though IntelliJ costs a bit you get a free evaluation license for a month. Download and installation is straightforward and easy. First noticed difference is the general workspace layout. In IntelliJ the eclipse-workspace is a project and a eclipse-project is a module. Further more IntelliJ configures things globally in your home directory and most settings are read from there no matter where you got your IntelliJ working directory with all your projects/modules. This is quite different to Eclipse where all workspaces are configured inside themselves in .metadata/ folder, and opening this workspace is completely uncoupled from any user-settings outside the workspace. It&#8217;s different, but is difficult to say which strategy to prefer, both got pros and cons, so I want to dig deeper what advantages exist inside IDE.</p>
<h3>IntelliJ taking ahead</h3>
<p>Following things I would emphasize when it comes to advantages of IntelliJ:</p>
<h4>Clear IDE Layout</h4>
<p>Generally the IntelliJ IDE layout and the look-and-feel is more tidied up and clear. You don&#8217;t have the millions of perspectives and views as in Eclipse. There is only one perspective with the main editor at center. On left, right and bottom you can find the so called &#8216;Tool-Windows&#8217; (can be compared to Eclipse views). Also you can focus Tool-Windows better and discard them again: Alt+F1 jumps to respective window, pressing Alt+F1 closes it again. This way you tend to only have the Tool-Windows open, which you currently use. In eclipse I often end up with many opened up views, which I am not interested in. Further more you can change opened files in tab-bar very quickly by hitting Strg-Right/Left. When being in project view it is possible that a file gets opened in editor as soon as you focuse a file (in Eclipse this is only possible if file is already opened in a tab). To summarize I like the general IDE navigation much better in comparison to Eclipse.</p>
<h4>Change History</h4>
<p>This one is a real delight! In Eclipse I always found the Local-History, where you can track changes very clumsy and difficult to follow. In IntelliJ this is a big feature, you can follow your changes very well and can label them locally, so reverting is just a wink of an eye. This is very handy if you got a bigger refactoring or feature task, which includes certain steps. In Eclipse I tend to check-in many little changes to version control in a short (minutes-scale) time though I would like to commit only complete tasks (which other team members are interested in only). This is possible with IntelliJ: with the great change history feature I am still commiting in short iterations but at the same time only complete things. Last but not least the diff-view is much better as in Eclipse.</p>
<h4>Dependency Matrix/General analyzations</h4>
<p>IntelliJ 7.x version introduced the dependency matrix, where you can analyze dependencies between packages and thus can identify coupling problems of subsystems. Generally the analyzations of your project is better as in Eclipse. With Alt+F7 you can quickly see all incoming dependencies. The analyzation-syntax-highlighting is very helpful to concentrate on the essential code bits, too. For instance when pressing Strg+Shift+F7 over a variable, read (blue-color) and write (pink color) access are highligthed. This can come very hand when refactoring large methods. Eclipse got this grey highlighter when you got your caret over a text-bit, but it vanishes as soon as your cursor moved somewhere else and you can highlight only one thing at one time.</p>
<h4>Intentions</h4>
<p>Intentions are a way to save you work from doing things manually though a certain context should offer you this task done automatically. Example: When placing the caret over an interface just press Alt+Enter and you are offered to create an implementing class with method-skeletons. When just typing a method call which does not exist, you get offered to create a method-body with respective signature. Since Eclipse 3.3.2 this feature is partly also introduced but not in such a good way as with IntelliJ.</p>
<h4>Auto-Save of changes</h4>
<p>In Eclipse I am constantly pressing Strg+S to save my changes. This can be very annoying, because I do a save very often straight after editing before executing a test case or starting the application. IntelliJ takes off this burden and does an auto-save behind the scenes. I really wonder why Eclipse isn&#8217;t doing the same, maybe it could be a performance issue, because recompile is done after each save. IntelliJ seems to handle this auto-compile very good, if errors occur you get to know the compile problem instantly.</p>
<h4>Plugin installation</h4>
<p>Though standard IntelliJ comes with enough functionality, for some special things you still need to get some plugins (e.g. Jetbrains groovy/grails plugin). Never the less I found the search and installation much more straightforward as with Eclipse where you really can get headaches especially if there are some transitive plugin dependencies. Further more you are informed if an update got released.</p>
<h4>Little things, big impact&#8230;</h4>
<p>Generally little things make a big difference. In IntelliJ there are so many that I cannot list all of them, but here a some which quickly come into my mind:</p>
<ul>
<li>When searching for a type (Ctrl+N) you can add a shortcut name of a type: Entering VQTB would quickly pop up (VeryQuickTypeBrowsing), this saves a lot of typing. You can further more quickly decide whether to include only own project types or dependency projects/third-party libs, too. This way you don&#8217;t get overhelmed by the millions of classpath-artifacts.</li>
<li>Unit-testing: If you are inside a JUnit test-class, pressing Strg+Shift+F10 outside a test method (or F9 for debug mode) executes all test-cases, if you are inside a test-method with your caret and press same shortcut only this single test-case is run. This is very handy because I often only work with one test-case if I debug or add a feature. For regression then I like to run the whole test-class or the whole package for subsystem-tests, so I step outside the test-method for class-run or go to package in project explorer to run a package-test. Shift+F10 opens a Run-dialog  with last executions, so you can choose between last run test sets very quickly.</li>
<li>Actions on commit: In Subversion commit-dialog you can choose &#8216;Organize imports&#8217;, &#8216;Format code&#8217; or &#8216;Run inspections&#8217; so you can do some actions on the code you would normally forget often (at least I do so). This way you get a better state in version control, where all imports and the code formatting is alright. Annoying diffs where you only see changes in different formatted code or unused imports should be vanished then.</li>
<li>Tip of the day: If actions need some time (e.g. building project) you see a little dialog, where some nice shortcuts or general IDE tips are presented. This way without explicitly reading the online help, you learn a lot while just working normally with the IDE day by day.</li>
</ul>
<h3>Eclipse taking ahead</h3>
<p>Of course there are some advantages of Eclipse, when compared to IntelliJ:</p>
<h4>OSGi support</h4>
<p>Eclipse migrated their former proprietary plugin architecture to standard OSGi platform to master the complexity of all these plugin dependencies and general plugin startup issues, which works great. Through the direct support of OSGi writing applications for the OSGi platform goes very well. OSGi Plugin for IntelliJ exists, but is far not as good as Eclipse with its equinox runtime and PDE environment.</p>
<h4>Mylyn</h4>
<p>I think Mylyn is a big plus for Eclipse, because it takes team collaboration with tracking-tools as a first child. With Mylyn you integrate common ticket-tools and can connect tickets with certain artifacts (packages, classes, other files etc.). There are many of mature Mylyn connectors (Bugzilla, trac, JIRA), which work very well. For IntelliJ you can choose from some ticket-tool integration plugins, but I did not perceive them as good as the Mylyn solution.</p>
<h4>Eclipse Modeling Project</h4>
<p>The <a href="http://www.eclipse.org/modeling/" target="_blank">Eclipse Modeling Project</a> for doing MDSD looks very promising (though I must admit I only read articles about it, but haven&#8217;t tried it out yet). After searching on the web I could not find an equally mature MDSD platform or plugin (like the one from <a href="http://www.openarchitectureware.org/" target="_blank">oaw</a>) for IntelliJ.</p>
<h3>IDE synchronization</h3>
<p>IntelliJ offers a simple eclipse project files export (.project, .classpath meta-data), so checked in Intellij modules can be used by Eclipse. Still I must admit that I did not elaborate enough, whether the IDE bridge/export between Eclipse and IntelliJ could generally work in a bigger team. Especially the synchronization of plugin metadata (like maven2, AspectJ) should not work without problems.</p>
<h3>Summary</h3>
<p>There is no size-fits-all IDE. On top of it is often difficult to say which IDE is better, because the quality and functionality also depends on the released plugins (e.g. maven2 eclipse plugin is better with Eclipse, groovy/grails plugin is better with IntelliJ). The automatic and safe refactorings, which I heard was always a big plus of IntelliJ are in my perception equally mature to the ones of Eclipse. In my view IntelliJ has other very nice points. Apart from the ones I mentioned above, there are many other little things which added together make the real IDE difference, where you are always close to the keyboard got control over so many things. In my view in many circumstances (when not developing for OSGi platform, RCP-apps or because of other plugin-show stoppers) IntelliJ is definetely worth the money and can increase productivity if your are willing to invest some time to switch. The pricing is moderate and as an Open Source developer it is for free.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.aldana-online.de/2008/05/21/eclipse-vs-intellij/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Improving weak automatic test-suites incrementally</title>
		<link>http://www.aldana-online.de/2008/05/13/improving-weak-automatic-test-suites-incrementally/</link>
		<comments>http://www.aldana-online.de/2008/05/13/improving-weak-automatic-test-suites-incrementally/#comments</comments>
		<pubDate>Mon, 12 May 2008 23:32:11 +0000</pubDate>
		<dc:creator>manuel aldana</dc:creator>
		
		<category><![CDATA[Continous Integration]]></category>

		<category><![CDATA[Software Engineering]]></category>

		<guid isPermaLink="false">http://www.aldana-online.de/2008/05/13/improving-weak-automatic-run-test-suites-incrementally/</guid>
		<description><![CDATA[A key element for good quality software is a good automatic run test-suite, which contains both unit and integration tests. As Frederic P. Brooks already mentions in his book &#8216;The Mythical Man-Month&#8217;, developers (as other humans, too) are far away from being perfect. As software from the outside view often needs to be written 100% [...]]]></description>
			<content:encoded><![CDATA[<p>A key element for good quality software is a good automatic run test-suite, which contains both unit and integration tests. As Frederic P. Brooks already mentions in his book &#8216;The Mythical Man-Month&#8217;, developers (as other humans, too) are far away from being perfect. As software from the outside view often needs to be written 100% correctly (only one missing or wrong statement in the whole execution path can make a feature to be buggy), we need to have a reliable way to get quick feedback whether something works or has been broken. A powerful way to accomplish this is by checking the behaviour with automatic running test-cases. Though this practice is already state of the art, you often find systems with a weak test-suite. This article shows why the feedback-loop is so important to how improve your test suite by getting a testing culture and to introduce test-cases step by step.<br />
<span id="more-116"></span></p>
<h3>Tests give you invaluable feedback</h3>
<p>In following situations the feedback of tests is very helpful or even essential:</p>
<ul>
<li>Existing tests tell you that you didn&#8217;t break existing behaviour after doing adaptions. These regression tests show you a green bar if a code change did not affect working features.</li>
<li>Tests help you to introduce new features. Writings new tests is done in parallel when touching production code. This way you can concentrate on this single feature and you further more get a quick response, whether the feature is implemented correctly (green bar) or not (red bar).</li>
<li>Tests help you to reproduce a bug. You write a new test case which shows you a the bug as a red bar. With this you have a very good starting point to debug and fix it. When fixed you get a positive response (green bar shows up).</li>
</ul>
<h3>The dilemma of weak test-suites</h3>
<p>Of course one single test-case won&#8217;t do the catch. Your aim should be have many test-cases which summed up represent your whole strong test suite. Unfortunately test suites are often weak, especially when changing code they don&#8217;t give you a red bar if something has been broken. The reason why a test suite is weak can be manifold:</p>
<h4>No practice of testing, too few tests</h4>
<p>The view of tests as central &#8220;development-drivers&#8221; is not practiced. Things are implemented and after that roughly tested in a manual way. There is no coding of automatic tests which prove that bug-fixes are done correctly or features work like specified. Testcode is seen as not-so-important stuff, because it does not show up in the production code and this way does not give real additional value to the customer.</p>
<h4>Tests aren&#8217;t executed regularly</h4>
<p>Tests which are part of the test suite exist, but their execution is not part of the build. Thus they are hardly executed and are triggered manually. Often this is the case because the tests need human intervention and cannot be run automatically by a build server or similar. It also can be that in fact you have a completely automatic test suite but is just not common that it is executed often. If tests aren&#8217;t executed regularly (e.g. once a day, after each commit), you lose the advantage of quick feedback. With this running the tests after a week/month or so, you don&#8217;t know what code change caused the test failures or errors. After a while developers will get reluctant about tests, they will be getting used to red bars and simply put will just ignore them at some point. In the end tests won&#8217;t be maintained and your test code gets more a burden than a help. Finally your test-code decays to dead code.</p>
<h4>Missing or very expensive tools</h4>
<p>For test automation the proper tools are very important. Nowadays you get a lot of good open-source test tools (Fit, xUnit-frameworks). Never the less for some special areas it is not trivial how to automate some testing steps, especially in integration testing (e.g. setting up and validating smart-cards contents, or testing message-oriented/asynchronous systems in general). Some vendors sometimes provide some more advanced testing tools but these are either very expensive or/and cannot be extended for special problems.</p>
<h3>The dilemma solution</h3>
<p>Above mentioned constraints to get a good test-suite are often hard but can be tackled. First of all everyone in the team needs to understand that tests aren&#8217;t given to the customer but are inherent important to the development process. Well, you don&#8217;t include you favorite IDE to the customer, never the less you couldn&#8217;t create software without it, could you? Testing continously needs to be a new habit, so give the team some more time to dig into this, like planning trainings for JUnit or test automation in general. If the team starts to value tests there still could be the problem that there are hardly any automated tests, which can be very demotivating (&#8217;The where to start&#8230;?&#8217; issue). Never the less you can start up by writing tests for all new features you want to implement or for areas you want to refactor. When knowing a bug always reproduce a bug with a test case initially. After doing this for a while you will see how your backing safety-net will grow bigger and bigger. Of course the test cases of the test division won&#8217;t be replaced by newly introduced test cases of the developers. There still are many tests which are difficult or cannot be automated at all (like user acceptance or GUI tests). So see developer-testing as supplements and not replacements for the &#8220;traditional&#8221; tests. Of course the testers could also help to improve the automated integration tests, because they are more black box focused. In a very mature test focused process a tester for instance would attach a reproducing integration test to a bug report.</p>
<p>As mentioned not executed tests some day will end up as dead code. To avoid this introduce certain triggers (e.g. nightly, after each commit) to run your test suite. See the test runnings as part of the software build itself. This view is very powerful and is also recommended by the Continous Integration concept. If run very regularly developers will soon start to appreciate the tests and will have &#8220;fun&#8221; with extending test-suite. Looking at the visible green bar or getting rid of a red one can be very motivating.</p>
<p>In former times test tools often had been something more for the people in the test division. The picture has changed a lot. Automated tests created directly from the developers is state of the art and is supported by many useful and open-source tools (Fitness, xUnit, db-unit, Mock-Frameworks, soap-ui etc.). They are extensible and can be combined to get an even more powerful testing tool. Further more Continous Integration servers for running and triggering tests are mature, free and can be extended (CruiseControl, Continuum, Hudson etc.).</p>
<h3>Summary</h3>
<p>Generally the view of tests from the developers side has changed a lot. Especially since the rise of Unit-testing, some new integration test-tools and the concept of Continous Integration, test-creation by developers is much more common. Even if your organization has not introduced this practice you can do so by building up your test-suite incrementally and executing it regularly. The harder part will be to get the developers to a testing routine/culture but this effort will far be outweighed by the benefits.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.aldana-online.de/2008/05/13/improving-weak-automatic-test-suites-incrementally/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Bashing the refactoring criticism</title>
		<link>http://www.aldana-online.de/2008/04/17/bashing-the-refactoring-fears-practice-refactorings/</link>
		<comments>http://www.aldana-online.de/2008/04/17/bashing-the-refactoring-fears-practice-refactorings/#comments</comments>
		<pubDate>Thu, 17 Apr 2008 21:41:32 +0000</pubDate>
		<dc:creator>manuel aldana</dc:creator>
		
		<category><![CDATA[Software Engineering]]></category>

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

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

		<category><![CDATA[Software Maintenance]]></category>

		<guid isPermaLink="false">http://www.aldana-online.de/2008/04/17/bashing-the-refactoring-fears-practice-refactorings/</guid>
		<description><![CDATA[Refactoring (changing design of existing code while preserving behaviour) is a cruicial daily software engineering practice to make your system able to adapt for typical maintenance tasks like fixing bugs or feature enhancements. Still I perceive that refactoring still is not commonly done. This article presents the most common arguments against practicing refactorings and show [...]]]></description>
			<content:encoded><![CDATA[<p>Refactoring (changing design of existing code while preserving behaviour) is a cruicial daily software engineering practice to make your system able to adapt for typical maintenance tasks like fixing bugs or feature enhancements. Still I perceive that refactoring still is not commonly done. This article presents the most common arguments against practicing refactorings and show why most of them are wrong.<br />
<span id="more-114"></span></p>
<h3>Emphasis on outside visible behaviour</h3>
<p><u>Criticism:</u><br />
Software enginners are paid to create or adapt a system which offers some direct business value, in this means you are claimed to fix a critical bug as quick as possible (hotfix), to add an eye opening feature or to eliminate a performance bottleneck. All these adaptions obviously focus on outside visible behaviour, and they are the real reason (well, lets ignore the political decisions for now&#8230;) why customers use software and pay for it. So the customer is right when not spending money directly on software maintenance.<br />
<u>Disproof:</u><br />
Simply put: The customer is completely right! It should not be his business to know the insights of how we develop software. In the end the system should work as wanted and he must feel that the system is making his life easier. Never the less that does not mean that we should ignore maintainability. With keeping our design and code clean with refactorings we can react on customers needs much more quickly. If he wants a new feature or a quick bug-fix we are in the very good position to offer a new release after a short time, because the code and design is clean and thus code changes do not need ages. Here we got two advantages: The customer will be more pleased to get a new release soon and we software engineers get more resources to improve the functionality of the system.</p>
<h3>The perfect all-solving upfront designed software</h3>
<p><u>Criticism: </u><br />
I do not need to refactor because my software is designed perfectly in the first place. It regards all extensions from the beginning on and thus can react quickly to changing business needs.<br />
<u>Disproof:</u><br />
Well, I doubt that&#8230; Above assertion claims that you can look into the future where you know all market changes and upcoming requirements. This is quite unrealistic except you believe in crystal balls&#8230; The other way to make your software ready for the future is that you try to make your design ready for all possible changes. This won&#8217;t work because you are speculating and you are paying the speculation fee with an overly complex system. This harms maintainability because the system contains loads of code which will be never used/run (dead code) and the design is much more difficult to understand. Further more you are wasting resources to make your system pseudo-future ready.</p>
<h3>Technology constraints</h3>
<p><u>Criticism: </u><br />
Refactoring is only doable with statically typed languages like Java or C#. The refactoring tools of respective IDEs (IntelliJ, Eclipse, VisualStudio etc.) are making refactorings possible.<br />
<u>Disproof:</u><br />
Refactoring is a concept and not based on technologies! It is a way to keep software maintainable. Of course it is correct that especially static typed languages (like Java without use of reflection api) make refactorings easier as dynamic language constructs (Java reflection api, Python, PHP etc.). The meta-data inside your code makes refactorings safer and tool support can be more powerful. Never the less you can refactor with any technology as long as you know your tools well and can overlook the side-effects your refactorings steps can cause.</p>
<h3>Blurry view of &#8220;good&#8221; design</h3>
<p><u>Criticism: </u><br />
In contrast to real world architecture where you are constrained by physic laws (otherwise your building will collapse somehow) the software-solution set for solving problems is much broader. There are innumerable ways to implement requirements and the judging whether it was done well or not is often quite subjective. Though you can find some objective metrics to measure software structure (lines of code per class/method) they still cannot express all aspects of maintainable software. How the heck could a computed metric tell you whether your namings are good, or if the relation between classes/packages well expresses the domain or requirements? So design generally is too subjective to get all developers under the hood.<br />
<u>Disproof:</u><br />
Yes, software design and code quality in many ways is quite subjective, never the less there are common agreements what good design is and what principles should be followed: inversion of control, design for testability, open/close principle, encapsulation, maximize cohesion etc.. Some code quality bits can be subjectively measured and be integrated as quality metrics, like a method must not exceed a certain number of method lines of code (MLOC) or cyclomatic complexity should be under 10. But you&#8217;re right that metrics themselves will never express the complexity of software as a whole. That&#8217;s why design and manual code reviews should be carried out to spread design/code knowledge and to find out areas which should be improved. To summarize: You more or less can &#8220;measure&#8221; good design/code quality by both using subjective (metrics) and objective (manual review) practices.</p>
<h3>System is too big to refactor</h3>
<p><u>Criticism:</u><br />
We realize that refactoring is a good practice but our system is just to big and we would need to spend just too much effort to make it noticeably better.<br />
<u>Disproof:</u><br />
It is true that you can feel overhelmed by a big muddle of mud system but improving systems can be done in an incremental way. You could start with little code bits, for instance by refactoring code areas you are touching often. Think it like a desert: There is a lot to do but you can create some little oases which after a while getting bigger and one day will connect each other to form big green forests.</p>
<h3>Refactorings are causing performance bottlenecks</h3>
<p><u>Criticism:</u><br />
When going towards refactoring you often end up with many little classes and methods with mostly little blocks (<15 MLOC). This is having an impact on performance because (to use Java as example) the JVM has to load many classes. The little methods are also causing performance problems because of the delegating calls through stack pop/push operations behind the scenes.<br />
<u>Disproof:</u><br />
Performance is a very important non-functional criteria, but it is always tricky to speculate what can cause the bottlenecks and to generally write less maintainable code (monster classes, monster methods) for the performance sake. With powerful hardware nowadays in most cases performance problems have other reasons (like database or network calls). This is different compared to former times, where main memory was rare and performance could be hit on language level, too. Today we got better development environment and should focus on developing maintainable code in the first place. If we experience performance issues this should be surrounded by a profiler-test to be able to draw the right conclusions.</p>
<h3>Untested legacy Code</h3>
<p><u>Criticism: </u><br />
In practice you hardly will find green-field projects, where you can follow refactoring practices from the beginning. Generally you start up with a bunch of existing code which you need to adapt. Often test coverage of the system (which is a symptom of legacy code) is not high enough to do manual refactoring steps. There is always the danger that you are unknowingly breaking existing behaviour. Especially refactoring beginners trying to dig into this topic often have to deal with the hardest untested legacy code issues, where usually you need well experienced software engineers to successful accomplish bigger refactorings. Thus the learning curve for refactoring &#8220;real world systems&#8221; is quite steep and is frustrating.<br />
<u>Disproof:</u><br />
Well, this is a very hard one in my opinion quite true in reality (so the disproof is a bit misplaced here&#8230;). The only solution for that is to face the devil, practicing and reading a lot! For example start to refactor little private projects you coded a few years ago or just get some code being written by others (regarding this the open-source world is like paradise). After a while you get accustomed and refactoring gets a good habit in your daily job. I know the first steps will be hard, but give it some time and you will ask yourself how you could develop software without the refactoring concept. My favorite book talking about doing refactorings with untested legacy code is magnificent book <a href="http://www.amazon.de/Working-Effectively-Legacy-Robert-Martin/dp/0131177052/ref=sr_1_1?ie=UTF8&amp;s=books-intl-de&amp;qid=1208463377&amp;sr=8-1" target="_blank">by Michael Feathers</a>. Apart from that one I highly recommend <a href="http://www.amazon.de/Refactoring-Large-Software-Projects-Restructurings/dp/0470858923/ref=sr_1_1?ie=UTF8&amp;s=books-intl-de&amp;qid=1208464950&amp;sr=8-1" target="_blank">Refactoring in large projects</a> and <a href="http://www.amazon.de/Refactoring-Patterns-Joshua-Kerievsky/dp/0321213351/ref=sr_1_6?ie=UTF8&amp;s=books-intl-de&amp;qid=1208464855&amp;sr=8-6" target="_blank">Refactoring to patterns</a>.</p>
<h3>Summary</h3>
<p>I presented some issues why many people are sceptical against practicing refactoring. I discussed why respective arguments are non-issues and think that in every organization refactoring should be emphasized. I know getting accustomed to new habits is often uncomfy, never the less give it a chance and believe me that preserving and restructuring existing systems can be a very creative work, you feel much better about your software and after all it&#8217;s big fun.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.aldana-online.de/2008/04/17/bashing-the-refactoring-fears-practice-refactorings/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
