<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Tom on Software Engineering</title>
	<atom:link href="http://tippexx.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://tippexx.wordpress.com</link>
	<description>Opinions and Solutions from a Software Engineer</description>
	<lastBuildDate>Tue, 12 May 2009 09:52:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='tippexx.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Tom on Software Engineering</title>
		<link>http://tippexx.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://tippexx.wordpress.com/osd.xml" title="Tom on Software Engineering" />
	<atom:link rel='hub' href='http://tippexx.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Quick Hack: Replace a separator with newline</title>
		<link>http://tippexx.wordpress.com/2009/05/12/quick-hack-replace-a-separator-with-newline/</link>
		<comments>http://tippexx.wordpress.com/2009/05/12/quick-hack-replace-a-separator-with-newline/#comments</comments>
		<pubDate>Tue, 12 May 2009 09:50:42 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Nothing Special]]></category>
		<category><![CDATA[cygwin]]></category>
		<category><![CDATA[editor]]></category>
		<category><![CDATA[newline]]></category>
		<category><![CDATA[replace]]></category>
		<category><![CDATA[sed]]></category>
		<category><![CDATA[separator]]></category>
		<category><![CDATA[ultraedit]]></category>

		<guid isPermaLink="false">http://tippexx.wordpress.com/?p=98</guid>
		<description><![CDATA[Most programmers will know the situation: you want to analyze the console output of some program but program spits the interesting section all in a single line. You want to separate the single strings and put them each in a separate line. How do you do it? In Unix, this is relatively easy using the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tippexx.wordpress.com&amp;blog=5125241&amp;post=98&amp;subd=tippexx&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Most programmers will know the situation: you want to analyze the console output of some program but program spits the interesting section all in a single line. You want to separate the single strings and put them each in a separate line. How do you do it?</p>
<p>In Unix, this is relatively easy using the sed tool (using &#8220;;&#8221; as separator):</p>
<pre class="brush: java;">
sed -e &quot;s/;/\\n/g&quot; myfile.txt
</pre>
<p>But Windows doesn&#8217;t provide a built-in tool for things like that, and shell emulators like cygwin are not available on all computers.</p>
<p>However, if you have access to Ultraedit, you can simply to a Search &amp; Replace. Search for your separator (&#8220;;&#8221;) and replace it with &#8220;^p&#8221;. Voila, you just created a readable list of your output.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tippexx.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tippexx.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tippexx.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tippexx.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tippexx.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tippexx.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tippexx.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tippexx.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tippexx.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tippexx.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tippexx.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tippexx.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tippexx.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tippexx.wordpress.com/98/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tippexx.wordpress.com&amp;blog=5125241&amp;post=98&amp;subd=tippexx&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tippexx.wordpress.com/2009/05/12/quick-hack-replace-a-separator-with-newline/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bc7aa56e8e004e4984e954e5e4cb2bc0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">TomTom</media:title>
		</media:content>
	</item>
		<item>
		<title>Ant Tasks and the &#8220;update&#8221;-Property</title>
		<link>http://tippexx.wordpress.com/2009/03/29/ant-tasks-and-the-update-property/</link>
		<comments>http://tippexx.wordpress.com/2009/03/29/ant-tasks-and-the-update-property/#comments</comments>
		<pubDate>Sun, 29 Mar 2009 18:34:09 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[ant]]></category>
		<category><![CDATA[archive]]></category>
		<category><![CDATA[build]]></category>
		<category><![CDATA[jar]]></category>
		<category><![CDATA[war]]></category>
		<category><![CDATA[zip]]></category>

		<guid isPermaLink="false">http://tippexx.wordpress.com/?p=56</guid>
		<description><![CDATA[Ant&#8217;s default tasks include archiving tasks with which we can create zip, jar and war files in the course of our project&#8217;s build process. All these tasks offer the &#8220;update&#8221;-attribute for time-saving incremental builds. If this attribute is set to true, the target archive file will not be created from scratch if it already exists. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tippexx.wordpress.com&amp;blog=5125241&amp;post=56&amp;subd=tippexx&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Ant&#8217;s default tasks include archiving tasks with which we can create zip, jar and war files in the course of our project&#8217;s build process. All these tasks offer the &#8220;update&#8221;-attribute for time-saving incremental builds. If this attribute is set to true, the target archive file will not be created from scratch if it already exists.</p>
<p>Rather, ant checks the contents of the existing archive file and compares them to the files which are supposed to be archived. Any files that are not already in the archive (or which have changed since the last build) are then put in the already existing archive, overwriting existing files:</p>
<pre class="brush: xml;">
&lt;target name=&quot;jar-update&quot;&gt;
  &lt;jar basedir=&quot;DirToJar&quot; update=&quot;true&quot; destfile=&quot;test.jar&quot;/&gt;
&lt;/target&gt;
</pre>
<p>But what happens if you delete a file in the directory you want to archive? Does ant realize that you deleted the file and will also delete this file in the target archive file?</p>
<p>The answer to that question is: <strong>no, ant does not delete files from an archive file if the &#8220;update&#8221; atribute is set to &#8220;true&#8221;</strong>. This can lead to nasty surprises in some rare cases. However, deleting the target archive file (for example during a &#8220;clean&#8221;) solves this problem.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tippexx.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tippexx.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tippexx.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tippexx.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tippexx.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tippexx.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tippexx.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tippexx.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tippexx.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tippexx.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tippexx.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tippexx.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tippexx.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tippexx.wordpress.com/56/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tippexx.wordpress.com&amp;blog=5125241&amp;post=56&amp;subd=tippexx&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tippexx.wordpress.com/2009/03/29/ant-tasks-and-the-update-property/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bc7aa56e8e004e4984e954e5e4cb2bc0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">TomTom</media:title>
		</media:content>
	</item>
		<item>
		<title>Import Custom Tasks in Ant Scripts</title>
		<link>http://tippexx.wordpress.com/2009/03/27/import-custom-tasks-in-ant-scripts/</link>
		<comments>http://tippexx.wordpress.com/2009/03/27/import-custom-tasks-in-ant-scripts/#comments</comments>
		<pubDate>Fri, 27 Mar 2009 15:33:40 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[ant]]></category>
		<category><![CDATA[build]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://tippexx.wordpress.com/?p=74</guid>
		<description><![CDATA[I recently had to import custom ant tasks in an ant build.xml file. Custom ant tasks are usually shipped in a JAR file. Two options were available in the project&#8217;s context to make a custom ant task defined in a JAR file available in the build file. Those options are described below along the example [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tippexx.wordpress.com&amp;blog=5125241&amp;post=74&amp;subd=tippexx&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I recently had to import custom ant tasks in an ant build.xml file. Custom ant tasks are usually shipped in a JAR file. Two options were available in the project&#8217;s context to make a custom ant task defined in a JAR file available in the build file. Those options are described below along the example of the antcontrib ant library.</p>
<h3>Option 1: JAR file in %ANT_HOME%/lib</h3>
<p>If you put the antcontrib.jar file in the lib directory of your ant installation, the library will be available by default. All you have to do is to load the ant tasks from this library:</p>
<pre class="brush: xml;">
&lt;taskdef resource=&quot;net/sf/antcontrib/antlib.xml&quot;/&gt;
</pre>
<p>From this point on, all ant tasks defined in antcontrib.jar are available in your ant build file.</p>
<h3>Option 2: JAR file anywhere</h3>
<p>In most cases you don&#8217;t want to &#8220;dirty&#8221; your ant installation by putting a custom library in the lib directory. So, you have to specify the location of the JAR file (which would be in some sub directory of your project):</p>
<pre class="brush: xml;">
&lt;taskdef resource=&quot;net/sf/antcontrib/antlib.xml&quot;
  classpath=&quot;path/to/antcontrib.jar&quot;/&gt;
</pre>
<h3>Using namespaces in Ant</h3>
<p>To keep your custom ant tasks distinct from default ant tasks, you can add namespaces to each custom library. Here is a toy example:</p>
<pre class="brush: xml;">
&lt;project name=&quot;MyProject&quot; xmlns:antcontrib=&quot;net/sf/antcontrib&quot;/&gt;
&lt;taskdef uri=&quot;net/sf/antcontrib&quot;
  resource=&quot;net/sf/antcontrib/antlib.xml&quot;
  classpath=&quot;path/to/antcontrib.jar&quot;/&gt;

&lt;!-- now we have to use the prefix &quot;antcontrib:&quot; to access
  the antcontrib tasks --&gt;
&lt;antcontrib:foreach ... /&gt;
&lt;/project&gt;
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tippexx.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tippexx.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tippexx.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tippexx.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tippexx.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tippexx.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tippexx.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tippexx.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tippexx.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tippexx.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tippexx.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tippexx.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tippexx.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tippexx.wordpress.com/74/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tippexx.wordpress.com&amp;blog=5125241&amp;post=74&amp;subd=tippexx&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tippexx.wordpress.com/2009/03/27/import-custom-tasks-in-ant-scripts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bc7aa56e8e004e4984e954e5e4cb2bc0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">TomTom</media:title>
		</media:content>
	</item>
		<item>
		<title>Optimistic vs. Pessimistic Version Control</title>
		<link>http://tippexx.wordpress.com/2009/03/19/optimistic-vs-pessimistic-version-control/</link>
		<comments>http://tippexx.wordpress.com/2009/03/19/optimistic-vs-pessimistic-version-control/#comments</comments>
		<pubDate>Thu, 19 Mar 2009 17:53:15 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Software Philosophy]]></category>
		<category><![CDATA[optimistic]]></category>
		<category><![CDATA[pessimistic]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[version control]]></category>

		<guid isPermaLink="false">http://tippexx.wordpress.com/?p=58</guid>
		<description><![CDATA[Version control is a vital element in every software project, since every project member responsible for software development or configuration management has to use it. Thus, the choice of the right tool should be well considered. With this choice comes the choice of a collaboration paradigm: optimistic version control or pessimistic locking of the resources [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tippexx.wordpress.com&amp;blog=5125241&amp;post=58&amp;subd=tippexx&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Version control is a vital element in every software project, since every project member responsible for software development or configuration management has to use it. Thus, the choice of the right tool should be well considered. With this choice comes the choice of a collaboration paradigm: optimistic version control or pessimistic locking of the resources contained in the project repository. Both paradigms offer a solution to resolving or avoiding conflicts when two developers want to access the same resource at the same time.</p>
<h3>Optimistic Version Control</h3>
<p>Optimistic version control is the default setting in prominent tools like CVS or Subversion. A conflict is created and resolved the following way:</p>
<ul>
<li>Persons A and B get resource X from the repository</li>
<li>Person A checks his changes into the repository</li>
<li>Person B tries to check in his changes and is alerted of a conflict</li>
<li>Person B merges his changes into the version of X checked in by Person A</li>
</ul>
<h3>Pessimistic Locking</h3>
<p>Pessimistic version control avoids conflicts altogether by locking resources.</p>
<ul>
<li>Person A gets resource X from the repository, locking it</li>
<li>Person B tries to get resource X from the repository but cannot, since it is locked</li>
<li>Person A checks in his changes into the repository, unlocking resource X</li>
<li>Person B can now get resource X from the repository an do his changes</li>
</ul>
<p>This technique is pessimistic in that it expects the worst, which in this case is persons A and B editing resource X at the same time.</p>
<h3>Why Pessimism is bad</h3>
<p>In my opinion, pessimistic version control is just a measure of some manager to let the poor developers feel who&#8217;s the boss. The term &#8220;pessimistic&#8221; alone should be enough to think about another solution (try explaining to someone not involved in software development why we are pessimistic about version control&#8230;).</p>
<p>The main reason for my opinion is the fact that while resources are locked by someone, <strong>no one else can work on these resources</strong>, effectively blocking the progress of everyone else, who just now needed to change something. Plus, if I want to change a resource someone else is currently blocking, I have to call this someone and tell him to drop me a note when he&#8217;s finished, which is organizational overhead. For resources that are changed often (like configuration files or central source files) this can be a severe problem!</p>
<p>I often hear the argument &#8220;But when a resource is locked, we don&#8217;t have to merge anymore. And merging is evil, because it is much work and error prone&#8221;. It is not. There are tools to help the developer to merge files. These tools are proven. In most cases you only have to look at the tools&#8217; output an confirm it. Merging files only gets nasty when a file has completely changed&#8230;which is rarely the case.</p>
<p>Another argument for pessimistic locking is this: &#8220;In large teams, many people are working on the same repository. Thus, optimistic version control would result in a lot of merging&#8221;. Besides the previous argument that merging is neither difficult nor dangerous, a large team should work on a large project. What is the chance that 2 out of 20 developers try to access the same resource (out of 20 000) at the same time?</p>
<p>Additionally to the above argumentation for optimistic version control I have had some rather bad experiences with pessimistic version control. Someone always forgets to check his sources back into the repository. Very frustrating if this someone is not reachable by phone because he&#8217;s sick or on vacation. Furthermore, not all tools boasting the locking feature really work. In my case, the locking mechanism didn&#8217;t always work and you had to merge anyways. Or the tool let the developer choose whether to lock or not. This made it possible for Person B to check in his changes while Person A had the resource locked&#8230;automatically creating a branch without letting the developer know this. I don&#8217;t want to know what changes were lost due to this bug&#8230; . Very ugly, indeed.</p>
<p>So&#8230;why not let the developers actually work instead of letting them twiddle their thumbs while waiting for someone to release a lock?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tippexx.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tippexx.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tippexx.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tippexx.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tippexx.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tippexx.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tippexx.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tippexx.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tippexx.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tippexx.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tippexx.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tippexx.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tippexx.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tippexx.wordpress.com/58/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tippexx.wordpress.com&amp;blog=5125241&amp;post=58&amp;subd=tippexx&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tippexx.wordpress.com/2009/03/19/optimistic-vs-pessimistic-version-control/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bc7aa56e8e004e4984e954e5e4cb2bc0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">TomTom</media:title>
		</media:content>
	</item>
		<item>
		<title>Code Smell: Constants Interfaces</title>
		<link>http://tippexx.wordpress.com/2009/02/24/code-smell-constants-interfaces/</link>
		<comments>http://tippexx.wordpress.com/2009/02/24/code-smell-constants-interfaces/#comments</comments>
		<pubDate>Tue, 24 Feb 2009 19:28:37 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Code Smells]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[code smell]]></category>
		<category><![CDATA[constants]]></category>
		<category><![CDATA[interfaces]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[refactoring]]></category>
		<category><![CDATA[Software Philosophy]]></category>

		<guid isPermaLink="false">http://tippexx.wordpress.com/?p=43</guid>
		<description><![CDATA[As I am currently refactoring the code of an application created by an insurance company, I will document some code smells I encountered. This way, I will be reminded if I am ever tempted to create such code myself. I&#8217;ll begin with constants interfaces, which are a legacy of pre-Enum days and lazy coders. Constants [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tippexx.wordpress.com&amp;blog=5125241&amp;post=43&amp;subd=tippexx&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>As I am currently refactoring the code of an application created by an insurance company, I will document some code smells I encountered. This way, I will be reminded if I am ever tempted to create such code myself. I&#8217;ll begin with constants interfaces, which are a legacy of pre-Enum days and lazy coders.</p>
<h3>Constants Interfaces</h3>
<p>Constants Interfaces are created in order to save the lazy coder some key strokes. A constants interface is an interface defining nothing but constants and looks like this:</p>
<pre class="brush: java;">
public interface MyConstants {
  public static final String MY_CONSTANT_1 = &quot;foo&quot;;
  public static final String MY_CONSTANT_2 = &quot;bar&quot;;
  // ...
}
</pre>
<p>This interface can then be &#8220;implemented&#8221; by other classes  that need access to the constants. The constants can be used without the prefix &#8220;MyConstants.&#8221;.</p>
<pre class="brush: java;">
public class MyClass implements MyConstants{
  public void doSomething(){
    System.out.println(MY_CONSTANT_1 + MY_CONSTANT_2);
  }
}
</pre>
<p>Why is this bad? There are several reasons (some of which may be subject to flavor-discussions).</p>
<h3>The Code Smell</h3>
<p>First of all, interfaces were designed to describe the <em>behavior </em>of a component (i.e. its methods). Thus, an unbiased programmer <em>expects </em>an interface to describe behavior and will be irritated if he only finds constants.</p>
<p>Second, the use of such an interface encourages the habit of simply implementing the interface, even if only one or two of perhaps 50 constants are used. Thus, 48 constants are visible in the implementing class but are not used, which violates encapsulation. Furthermore, if the implementing class is part of a class hierarchy, <em>all subclasses</em> will also have direct access to the constants defined through the interface. In my current refactoring assignment the constants of a single interface were visible in &gt;100 classes of a rather unflexible class hierarchy (which should also be subject to refactoring). Worse: some classes high up in that hierarchy implemented <em>more than one</em> constants interface, making all constants visible in sublasses.</p>
<p>Third, though admittedly a weak argument, using a constant with its class prefix (MyConstants.MY_CONSTANT_1) is more self-documenting than using the constant name alone. Assuming, of course, that the class and constants names are well chosen. If the class prefix is always used, the single advantage of constants interfaces is lost.</p>
<h3>Better Solutions</h3>
<p>In conclusion, interfaces defining nothing but constants are bad practice and should be avoided. If such interfaces are already present, they should be refactored into either enums or final classes with a private constructor.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tippexx.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tippexx.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tippexx.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tippexx.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tippexx.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tippexx.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tippexx.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tippexx.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tippexx.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tippexx.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tippexx.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tippexx.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tippexx.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tippexx.wordpress.com/43/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tippexx.wordpress.com&amp;blog=5125241&amp;post=43&amp;subd=tippexx&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tippexx.wordpress.com/2009/02/24/code-smell-constants-interfaces/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bc7aa56e8e004e4984e954e5e4cb2bc0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">TomTom</media:title>
		</media:content>
	</item>
		<item>
		<title>Starting a Blog</title>
		<link>http://tippexx.wordpress.com/2009/02/20/starting-a-blog/</link>
		<comments>http://tippexx.wordpress.com/2009/02/20/starting-a-blog/#comments</comments>
		<pubDate>Fri, 20 Feb 2009 18:58:13 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Nothing Special]]></category>
		<category><![CDATA[introduction]]></category>
		<category><![CDATA[Software Philosophy]]></category>

		<guid isPermaLink="false">http://tippexx.wordpress.com/?p=20</guid>
		<description><![CDATA[I have never possesed a diary or written a journal of some sort, but I guess writing seems to be a good way of summing up and re-thinking the things that happen. So, I thought I&#8217;d give blogging a try and write about the things that I spend most of my waking time with: Software [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tippexx.wordpress.com&amp;blog=5125241&amp;post=20&amp;subd=tippexx&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have never possesed a diary or written a journal of some sort, but I guess writing seems to be a good way of summing up and re-thinking the things that happen. So, I thought I&#8217;d give blogging a try and write about the things that I spend most of my waking time with: Software Engineering. This job is special in that it can be a hobby, too, so I enjoy reading about it. Hopefully, I will also enjoy writing about it <img src='http://s2.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . And perhaps some of the things I write will be interesting or even helpful to some readers.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tippexx.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tippexx.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tippexx.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tippexx.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tippexx.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tippexx.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tippexx.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tippexx.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tippexx.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tippexx.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tippexx.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tippexx.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tippexx.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tippexx.wordpress.com/20/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tippexx.wordpress.com&amp;blog=5125241&amp;post=20&amp;subd=tippexx&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tippexx.wordpress.com/2009/02/20/starting-a-blog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bc7aa56e8e004e4984e954e5e4cb2bc0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">TomTom</media:title>
		</media:content>
	</item>
	</channel>
</rss>
