<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Roop says</title>
	<atom:link href="http://danielroop.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://danielroop.com/blog</link>
	<description>I created gravity?</description>
	<lastBuildDate>Sun, 22 Jan 2012 02:05:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Obsessed with REST</title>
		<link>http://danielroop.com/blog/2012/01/21/obsessed-with-rest/</link>
		<comments>http://danielroop.com/blog/2012/01/21/obsessed-with-rest/#comments</comments>
		<pubDate>Sat, 21 Jan 2012 22:03:59 +0000</pubDate>
		<dc:creator>Daniel Roop</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[rest]]></category>
		<category><![CDATA[theory]]></category>

		<guid isPermaLink="false">http://danielroop.com/blog/?p=128</guid>
		<description><![CDATA[Early in my career I discovered my first love in programming, the build processes. I have identified it as various things over the years; build tools, unit testing, continuous integration and now continuous delivery, but it will always be my &#8230; <a href="http://danielroop.com/blog/2012/01/21/obsessed-with-rest/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Early in my career I discovered my first love in programming, the build processes.  I have identified it as various things over the years; build tools, unit testing, continuous integration and now continuous delivery, but it will always be my first love in programming.  Over the last two years I have found a new love, REST.  The great thing is these two are completely comfortable with each other and work very well together.</p>
<p>As I haven&#8217;t blogged very much over the time I have gained this new obsession I have lots in the backlog to write about.  But as a wise friend, <a href="http://adamfortuna.com/" title="Adam Fortuna">Adam Fortuna</a>, once told me it so annoying to have a &#8220;I am going to start blogging again post&#8221;.  I acknowledge this paragraph is in itself an acknowledgment of my failure, I will attempt to provide some value to hide my failure.</p>
<p>While digging into REST I found numerous resources super helpful so I figured I would catalog them in this post for anyone else interested as my first foray into sharing my REST experience with everyone.</p>
<h2>Foundational Reading</h2>
<dl>
<dt><a href="http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm">Roy Fielding&#8217;s Dissertation that defined REST</a></dt>
<dd>This is the paper that started it all.  Roy Fielding coined the term REST and described what it was.  The majority of the disseration is establishing a mechanism for describing distributed architectures and I would recommend it to anyone interested in that topic regardless of your opinion of REST.  But I think it is foundational for anyone looking to understand REST beyond a practical level.</dd>
<dt><a href="http://www.amazon.com/gp/product/0596805829/ref=as_li_ss_tl?ie=UTF8&#038;tag=danroo-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0596805829">REST in Practice: Hypermedia and Systems Architecture</a><img src="http://www.assoc-amazon.com/e/ir?t=danroo-20&#038;l=as2&#038;o=1&#038;a=0596805829" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />
</dt>
<dd>There are a couple books published prior to this one by O&#8217;Reilly about REST, but I would recommend skipping those and starting here.  This book gives a lot of practical examples and has incorporated a few extra years of learning on top of the original &#8220;REST&#8221; books that were published.  Some of the generally accepted good practices have changed since the first round of books.  At work I gained the reputation of the REST Prophet and this book was considered my REST Bible.</dd>
<dt><a href="http://martinfowler.com/articles/richardsonMaturityModel.html">Martin Fowler on Richardson Maturity Model</a>
<dt>
<dd>The Ricardson Maturity Model is a way to categorize how &#8220;RESTful&#8221; an API is.  It is worth noting that Roy Fielding has stated that he only considers level 3 RESTful, but it is useful to categorize where APIs are.  Most public APIs stop at level 2.</dd>
</dl>
<h2>Good Example APIs</h2>
<ul>
<li><a href="http://developer.netflix.com/">Netflix</a></li>
<li><a href="http://kenai.com/projects/suncloudapis/pages/Home">Sun Cloud API</a></li>
<li><a href="https://developer.atlassian.com/display/REST/Guidelines+for+Atlassian+REST+API+Design">Atlassian</a></li>
</ul>
<h2>Shameless Plug</h2>
<div style="float:left;width:450px;margin-right:40px">
This isn&#8217;t really a shameless plug for me, but I did have the pleasure to work with a colleague to refine our perspective on REST and how it should be used within our organization.  Some of those ideas were bundled up and published in a book in late 2011.  It is a short book, but is chalk full of clear opinions about how to solve common questions like (what should my url look like, or should I use a custom content-type).  It then takes a stab at starting the wheels moving on a new standard Content-Type and framework for building and interacting with REST APIs.  I would recommend having this and REST In Practice next to you at all times if you are trying to leverage REST in your environments
</div>
<p><iframe src="http://rcm.amazon.com/e/cm?lt1=_blank&#038;bc1=000000&#038;IS2=1&#038;nou=1&#038;bg1=FFFFFF&#038;fc1=000000&#038;lc1=0000FF&#038;t=danroo-20&#038;o=1&#038;p=8&#038;l=as4&#038;m=amazon&#038;f=ifr&#038;ref=ss_til&#038;asins=1449310508" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://danielroop.com/blog/2012/01/21/obsessed-with-rest/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Confluence Bundle for Textmate (sortof)</title>
		<link>http://danielroop.com/blog/2010/03/19/confluence-bundle-for-textmate-sortof/</link>
		<comments>http://danielroop.com/blog/2010/03/19/confluence-bundle-for-textmate-sortof/#comments</comments>
		<pubDate>Fri, 19 Mar 2010 13:10:23 +0000</pubDate>
		<dc:creator>Daniel Roop</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[bundle]]></category>
		<category><![CDATA[confluence]]></category>
		<category><![CDATA[textile]]></category>
		<category><![CDATA[textmate]]></category>

		<guid isPermaLink="false">http://danielroop.com/blog/2010/03/19/confluence-bundle-for-textmate-sortof/</guid>
		<description><![CDATA[On and off I looked for a Textmate Bundle for Confluence with no luck. I was looking for something with basic syntax highlighting and maybe a preview view. It would be nice to have integration so I could publish from &#8230; <a href="http://danielroop.com/blog/2010/03/19/confluence-bundle-for-textmate-sortof/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>On and off I looked for a <a href="http://macromates.com/">Textmate</a> Bundle for <a href="http://www.atlassian.com/software/confluence/">Confluence</a> with no luck.  I was looking for something with basic syntax highlighting and maybe a preview view.  It would be nice to have integration so I could publish from textmate, but I wasn&#8217;t going to push my luck.  I happened to stumble across <a href="http://thinkwrap.wordpress.com/2007/05/17/using-wiki-markup-without-a-wiki/">this unrelated article</a> that points out a bit of information that I never paid any mind to before.</p>
<blockquote><p>
There is wide selection of various markups, the one I like the best is the Textile markup (which is implemented by many Wiki systems, including Confluence).
</p></blockquote>
<p>I quickly went back to Textmate because I was sure it had support for a standard markup language like <a href="http://en.wikipedia.org/wiki/Textile_(markup_language)">textile</a>, and sure enough it was part of the default settings.  I switched to it for a document I was working on, and while the syntax highlighting wasn&#8217;t great, the preview view worked.</p>
<p>I would still like to see a full blown confluence bundle, but it is a good temporary solution, and I hope it saves someone out there some grief in their search.</p>
]]></content:encoded>
			<wfw:commentRss>http://danielroop.com/blog/2010/03/19/confluence-bundle-for-textmate-sortof/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why Defensive Programming is Rubbish</title>
		<link>http://danielroop.com/blog/2009/10/15/why-defensive-programming-is-rubbish/</link>
		<comments>http://danielroop.com/blog/2009/10/15/why-defensive-programming-is-rubbish/#comments</comments>
		<pubDate>Fri, 16 Oct 2009 03:16:52 +0000</pubDate>
		<dc:creator>Daniel Roop</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[rant]]></category>
		<category><![CDATA[theory]]></category>

		<guid isPermaLink="false">http://danielroop.com/blog/2009/10/15/why-defensive-programming-is-rubbish/</guid>
		<description><![CDATA[There are many ways to classify a programming style. One of the classifications I hear a lot at my current place of employment is Defensive Programming. Before I worked here I had noticed the style but I don&#8217;t think I &#8230; <a href="http://danielroop.com/blog/2009/10/15/why-defensive-programming-is-rubbish/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>There are many ways to classify a programming style.  One of the classifications I hear a lot at my current place of employment is Defensive Programming.  Before I worked here I had noticed the style but I don&#8217;t think I had a word to describe the practice. Furthermore, if I had thought about a word to the describe the style I wouldn&#8217;t have called it Defensive.  I would have called it Hide the Problem Programming.  Before I get into my rant let me start by explaining the Defensive Programming philosophy.</p>
<blockquote>
<p>Defensive programming is a form of defensive design intended to ensure the continuing function of a piece of software in spite of unforeseeable usage of said software. The idea can be viewed as reducing or eliminating the prospect of Murphy&#8217;s Law having effect. Defensive programming techniques are used especially when a piece of software could be misused mischievously or inadvertently to catastrophic effect.</p>
<p>Courtesy Wikipedia http://en.wikipedia.org/wiki/Defensive_programming</p>
</blockquote>
<p>To be fair I don&#8217;t technically disagree with this practice, in fact I agree with it.  However, defensive programming in practice (at least in my experience) is taken past what is described above to a very sad and ugly place.  There are two things in particular that bother me:</p>
<ul>
<li>Unnecessary Code</li>
<li>Null Checks</li>
</ul>
<p>Let me break them down for you you.</p>
<h2 id="unnecessarycode">Unnecessary Code</h2>
<p>Most &#8220;Unnecessary Code&#8221; situations seem to be old habits that have been carried over from older languages.  I would actually understand many of them in a more dynamic language where you have no compile time checks to ensure program validity, but I see them much more often in static languages like Java.  This completely baffles me.</p>
<p>Would you ever do the following?</p>
<pre><code>Integer one = 1;
Integer two = one + one;

if (two &gt; one) {
    return "the world is right: 2 &gt; 1 is true";
}
</code></pre>
<p>If the answer is yes, please stop reading now because there is no way I could ever convince you of anything.  If the answer is no, there is hope for you yet.  This example is a bit extreme but it is a good starting point to demonstrate the ridiculousness of the practice.  Now let me try a more realistic scenario:</p>
<pre><code>public class Person {
    private String name = null;

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }
}

public Person newPerson(String name) {
    Person person = new Person(); 

    if (name != null) {
        person.setName(name);
    }

    return person;
}

public static void main(String[] args) {
    Person daniel = new Person("Daniel Roop");
}
</code></pre>
<p>This is a special case of a null check, which I will discuss next, but I see it all the time.  Why are you checking for it to be null, if the default value is null?  Why add the extra lines of code for no value at all.  Which leads me to my number 1 issues with &#8220;defensive programming&#8221;.</p>
<h2 id="nullchecks">Null checks</h2>
<p>I would recommend to never get me started on this topic.  I find null checks to be one of the most unnecessary, ridiculous, ugly practices in programming.  It is right up there with Util classes.  So let&#8217;s start with an example:</p>
<pre><code>public void addFriendToList(List&lt;Friend&gt; friends, Friend newFriend) {
    if (friends != null &amp;&amp; newFriend != null) {
        friends.add(newFriend);
    }
}
</code></pre>
<p>This one isn&#8217;t obviously ridiculous.  My problem with this scenario is that the person calling the method is requesting you add a friend to a list, but in the case where it provided incorrect inputs (like null parameters) it just won&#8217;t do anything.    How is that helpful to anyone?  Yes, you will avoid a null pointer if the friends list is not initialized but</p>
<ul>
<li>It should always be initialized, if not the code calling the method is screwed up and appropriate feedback should be provided.</li>
<li>You should provide feedback when parameters are incorrect not hide the fact that something is wrong.</li>
</ul>
<p>Taking this example to the extreme you might see something like this</p>
<pre><code>public List&lt;Friend&gt; findFavoriteFriends(Person person) {
    List&lt;Friend&gt; favoriteFriends = new ArrayList&lt;Friend&gt;();

    if (person != null) {
        List&lt;Friend&gt; friends = person.getFriends();

        if (friends != null) {
            for (Friend friend : friends) {
                if (friend != null) {
                    if (friend.isFavorite()) {
                        favoriteFriends.add(friend);
                    }
                }
            }
        }
    }

    return favoriteFriends;
}

public static void main(String[] args) {
    Person person = PersonFactory.find("Daniel Roop");
    List&lt;Friend&gt; favoriteFriends = findFavoriteFriends(person);

    if (favoriteFriends != null &amp;&amp; favoriteFriend.size() &gt; 0) {
        for (Friend friend : favoriteFriends) {
            if (friend != null) {
                System.out.println(friend.getName());
            }
        }
    }
}
</code></pre>
<p>Why do I care?  Does it hurt anything to have these extra checks?  From a logic perspective the answer is no, but I would argue from a readability, correctness, and maintenance standpoint yes very much.  </p>
<h3 id="readability">Readability</h3>
<p>I believe code should be written in a way to express the intent through the source (not through commenting).  Beside my wonderful method names, I don&#8217;t think you would have any clue what the method was attempting to do at first glance. Furthermore, even with those amazing method names, I would argue if you read the main method you couldn&#8217;t tell me what was going on.  </p>
<h3 id="correctness">Correctness</h3>
<p>More importantly if something where to go wrong, and I actually did pass a null list I wouldn&#8217;t know.  I would just get an empty list back and assume my person had no favorite friends.  This is not the correct response, in fact it is the wrong response because I have many favorite friends (you the reader are of course one of them).  There is no indication to me that there is anything wrong. I, the caller, received an empty list which is a perfectly valid response, but it is wrong.</p>
<h3 id="maintenance">Maintenance</h3>
<p>This is really a combination of the two above.  Imagine a large application (let&#8217;s say a photo sharing application) with this type of code all over the place.  Now imagine you are given a defect that User A was not able to share an image with only their favorite friends.  When they select only share with favorite friends no one can see the photos, but they can see their friends are flagged as favorite in their friend list.  Where would you even start with that?  If you hadn&#8217;t been so &#8220;defensive&#8221; you would probably have an exception written to the log because when User A request their friend list they get a null instead, thus causing a null pointer in the findFavoriteFriends method.  This would not only give you a starting point for the bug, it would also trigger a notification of the problem before the User A complaint even reached the developers because your log monitor picked up the exception and notified the developers.  </p>
<p>On the other side, you now don&#8217;t know if those null checks where put in place because they were meaningful, or just fluff.  When I say meaningful I mean that a null value actually caries some information (e.g. null argument to a method means the parameter should not be used.)  The developer implementing a fix on this method will have to assume that the null check has some meaning and work around those checks instead of improving the business logic</p>
<h2 id="looseends">Loose Ends</h2>
<p>I must admit the title of this article is a bit of a misnomer.  When I began writing the article I agreed with the title, but after reading up on what Defensive Programming really is, I realized. I am a defensive programmer. Just not in the buzz word cop out sense.  If you don&#8217;t believe me maybe you will believe Ward Cunningham who has a wiki article on <a href="http://c2.com/cgi/wiki?OffensiveProgramming">Offensive Programming</a>, and points out Defensive Programming is the same as a FailFast approach which is closer to how I would write my code.</p>
<p>Let me be clear, I am not suggesting you should show stack traces to your end user.  But the fact of the matter is, something is wrong and often times I would imagine it is better to show nothing, then partial something.  A good example of this is the recent <a href="http://status.twitter.com/post/207632462/timeline-delays-this-morning">twitter outage</a> users were able to update their status, but there was no indication that no one could see the update.  This caused a lot of confusion and I heard much of the interwebs (at least the small corner I pay attention to) say that it would much rather a fail whale than a semi-up system.  What you should do instead is when there is an error with a request, catch it in your container (if it gets that far) and show a 500 message. Ideally logging the stack trace that will hopefully trigger a monitor to go off, and developers can investigate.</p>
<p>I can imagine this type of programming has it&#8217;s place, especially in embedded systems, but on the web they have no place.  You have a simple request response, if one request doesn&#8217;t work oh well, display an error and ask the user to try again. Most of the time that will be better than sort-of working.  And that is not to say there aren&#8217;t situations where non-mission critical pieces can be turned off if they don&#8217;t work, but the core functionality should not be written that way.</p>
<h2 id="conclusion">Conclusion</h2>
<p>If I have convinced you of nothing else I hope I can get you to take away two things</p>
<ol>
<li>Think about every null check you implement, and ask yourself is this necessary?</li>
<li>Stop calling what you are doing defensive programming, it is called &#8220;if I don&#8217;t see any errors there aren&#8217;t any errors programming&#8221; and it isn&#8217;t helpful to anyone.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://danielroop.com/blog/2009/10/15/why-defensive-programming-is-rubbish/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Program to an interface not an Interface</title>
		<link>http://danielroop.com/blog/2008/06/28/program-to-an-interface-not-an-interface/</link>
		<comments>http://danielroop.com/blog/2008/06/28/program-to-an-interface-not-an-interface/#comments</comments>
		<pubDate>Sun, 29 Jun 2008 03:30:47 +0000</pubDate>
		<dc:creator>Daniel Roop</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[rant]]></category>
		<category><![CDATA[social]]></category>
		<category><![CDATA[theory]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[gof]]></category>
		<category><![CDATA[interface]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[java interface]]></category>
		<category><![CDATA[static]]></category>

		<guid isPermaLink="false">http://danielroop.com/blog/2008/06/28/program-to-an-interface-not-an-interface/</guid>
		<description><![CDATA[For the longest time I have thought I was crazy, because I just didn&#8217;t see the benefit of programming to an Interface. I agreed it was good from a design perspective, but as an implementation I saw no need to &#8230; <a href="http://danielroop.com/blog/2008/06/28/program-to-an-interface-not-an-interface/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>For the longest time I have thought I was crazy, because I just didn&#8217;t see the benefit of programming to an Interface. I agreed it was good from a design perspective, but as an implementation I saw no need to add the extra code for what amounted to zero benefit. I have finally come to the conclusion that a good chunk of people have absolutely lost their mind.  I base that conclusion on the fact that I have found <a href="http://jroller.com/rolsen/">smart people</a> that agree with me, to counter the <a href="http://mockobjects.com">smart people </a>that lost their mind.</p>
<p>What am I talking about?  I will cut straight to the point, when the <a href="http://en.wikipedia.org/wiki/Gang_of_Four_(software)" title="Gang of Four">GoF</a> suggested programming to an interface not an implementation in their <a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&#038;location=http%3A%2F%2Fwww.amazon.com%2FDesign-Patterns-Object-Oriented-Addison-Wesley-Professional%2Fdp%2F0201633612%3Fie%3DUTF8%26s%3Dbooks%26qid%3D1214271753%26sr%3D1-1&#038;tag=danroo-20&#038;linkCode=ur2&#038;camp=1789&#038;creative=9325">classic book</a><img src="http://www.assoc-amazon.com/e/ir?t=danroo-20&amp;l=ur2&amp;o=1" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />, I don&#8217;t think they meant a Java Interface.  Mostly because the book was based on C++ and Java Interfaces weren&#8217;t around, but also because I think they are smarter than that.</p>
<p>Like so many things in the Java community, I think <abbr title="the java community">they</abbr> took a really great idea and twisted it until it no longer made sense.  I don&#8217;t think they do this on purpose, I believe they are just gluttons for theories.  But, before I get to far into this rant, let me substantiate this claim with a few points of interest.</p>
<ul>
<li>Almost all languages at the time of the GoF publication did not have the notion of an interface as a first class citizen.</li>
<li>The examples in the book were written in C++ which did not have the notion of an interface, although you can <a href="http://www.codeguru.com/cpp/cpp/cpp_mfc/oop/article.php/c9989/">fake it</a>.</li>
<li>Patterns are supposed to be reusable bits of object oriented goodness, and since all object oriented languages don&#8217;t include interfaces as first class citizens it might not be essential to use these ideas.</li>
</ul>
<p>Now let me switch into argument mode, I agree with the notion of programming to an interface.  I admit that doesn&#8217;t sound like a very good argument, but hear me out.  I will address each of the popular arguments individually, so what are they?</p>
<h3>If you don&#8217;t use an Interface you are programming to the implementation not the interface.</h3>
<p>So the point here is that you should be loosely coupling your classes in your application.  When designing your systems you should always think about the interface (coupling) between your components and make sure they make sense. I firmly believe the best way to make a maintainable system is to create loose coupling and high cohesion as a <a href="http://brianlegros.com">wise man</a> once taught me.  But this can and is done in many languages, and at many shops without the need for the Java Interface.</p>
<p>So what am I saying?  I am saying if I showed you the following code:</p>
<pre><code>
public class BankDelegate {
   public void debit(Account account, Amount amount) {
      account.debit(amount);
   }
}
</code></pre>
<p>you would have no idea if account was an Interface, Abstract Class, or Concrete Class.  And furthermore, I would suggest that it doesn&#8217;t matter.  Let&#8217;s say my bank only has a single account type.  This would work great.  Now what happens when I need to add a second account type?  I can either create a base class, that both my accounts extend from, or I can create an Interface.  Either solution will work, and I don&#8217;t need to change the code in my delegate.  Which means my interface has remained the same.</p>
<p>That is what it means to program to an interface.  Because if I had originally wrote the BankDelegate class like this:</p>
<pre><code>
public class BankDelegate {
   public void debit(CheckingAccount account, Amount amount) {
      account.debit(amount);
   }
}
</code></pre>
<p>Then my interface is only good for classes that are of type CheckingAccount.  So let&#8217;s apply the same logic as before.  I could write this as an Interface, Abstract Class, or Concrete Class and you would have no idea based on the above code.  But of course, had I written it as an Interface it would be loosely coupled, and therefore I would be able to change it extremely easy at a later time&#8230;Oh wait, errrrr&#8230;It doesn&#8217;t make sense for a SavingsAccount to extend Checking account.  I need to add a new base class or interface of Account and extend that.  It will take the same amount of work to change this to accept a SavingsAccount regardless of what notation I used to create the CheckingAccount type.</p>
<p>Because of that I would argue that programming to an interface is more about thinking about the names of your classes and methods than using a special notation to declare them.</p>
<h3>Why would you tie down your domain with unnecessary dependencies?</h3>
<p>This is the argument that if I don&#8217;t create an interface, I will be importing unnecessary third party dependencies into my domain.  The example I have seen suggests if you are creating a store, and you need to keep track of sales, you should create a SalesLedger interface.  That way you can create a HibernateLedger that implements the SalesLedger, so as to not couple the Hibernate libraries to your domain.  I agree with the idea of not coupling your domain with hibernate, but I don&#8217;t see how adding an Interface solves this.  Even if I make the Interface I could make it rely on hibernate functionality, especially if it is the first and only implementation I do.  Futhermore, the argument seems to suggest that I would have created the class HibernateLedger in place of SalesLedger if I had not created the Interface.  That is probably true from the implementation standpoint, but form the interface standpoint, the methods would be identical to SalesLedger, the Interface. Am I missing something?</p>
<p>More importantly however, it is not unnecessary from a runtime perspective, which is essentially the only time you are &#8216;importing the dependency&#8217; because without the Hibernate classes your code won&#8217;t work, no matter how many Interfaces you placed in between.</p>
<h3>How else can you change the implementation in the future?</h3>
<p>I am sorry, but this is ridiculous?  Let&#8217;s break this down into what that really means.<br />
1. If you mean changing it at runtime&#8230;that has more to do with the strategy pattern and your runtime environment, that a Java Interface.  If you needed to change an implementation at runtime, you simply extend the original class, change the behavior you need, and inject your new object.<br />
2. If you mean changing it for a future build&#8230;just re-write the code.  Will you need the old code?  Do you like keeping an archive of all your classes?  If you need to change your SalesLedger to use a web service, instead of hibernate, go for it.  You wouldn&#8217;t be using both at the same time.</p>
<p>So you ask, what if I need the old code in the future?  I would say, isn&#8217;t that what version control is for.</p>
<h3>What if we need to change the parameters in the future?</h3>
<p>This is the one that I find most disheartening.  The idea here is doing something like this</p>
<pre><code>
public void myMethod(IMyParameterInterface request) {
    ...
}
</code></pre>
<p>instead of this</p>
<pre><code>
public void myMethod(String param1, Integer param2) {
    ...
}
</code></pre>
<p>Talk about working around language features.  What if you need to change the parameters in the future you ask?  I don&#8217;t know change the parameters.  I know, the response is, well then your interface has changed, and you need to go update everyone consuming that interface.  Yeah, well guess what you just added a new parameter, that they probably need to send, and if they don&#8217;t, you can just overload the method and pass a null, which you would have to check for in your Interface based system as well.</p>
<p>So there you have it&#8230;</p>
<p>I recognize that Java Interfaces are essential to the language, because Java is a static typed language, and doesn&#8217;t allow multiple inheritance, Interfaces are the only way to create libraries like the collections API.  I think it is unfortunate that the word &#8216;interface&#8217; has been overloaded so much, that in this case it was taken literally becase and Interface type existed, instead of just treating it in the more generic term, of interface between two components or systems.</p>
<p>In conclusion, I hope I have enlightened, and annoyed a few people with this article.  And maybe I don&#8217;t know what I am talking about, but just incase I haven&#8217;t been able to convince you, read <a href="http://www.artima.com/lejava/articles/designprinciples.html">this interview</a> with Eric Gamma, I think you will find it enlightening.</p>
]]></content:encoded>
			<wfw:commentRss>http://danielroop.com/blog/2008/06/28/program-to-an-interface-not-an-interface/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>EasyMock Exception when calling createMock</title>
		<link>http://danielroop.com/blog/2008/05/22/easymock-exception-when-calling-createmock/</link>
		<comments>http://danielroop.com/blog/2008/05/22/easymock-exception-when-calling-createmock/#comments</comments>
		<pubDate>Fri, 23 May 2008 01:21:17 +0000</pubDate>
		<dc:creator>Daniel Roop</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[troubleshoot]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[exception]]></category>
		<category><![CDATA[mock]]></category>
		<category><![CDATA[test]]></category>

		<guid isPermaLink="false">http://danielroop.com/blog/2008/05/22/easymock-exception-when-calling-createmock/</guid>
		<description><![CDATA[I admit this is probably an obscure error, but I didn&#8217;t find anyone else talking about it. So, in an effort to help some other poor sap like me out&#8230; If you receive this error in EasyMock 2.3 java.lang.NoSuchMethodError: org.easymock.internal.RecordState.(Lorg/easymock/internal/IMocksBehavior;)V &#8230; <a href="http://danielroop.com/blog/2008/05/22/easymock-exception-when-calling-createmock/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I admit this is probably an obscure error, but I didn&#8217;t find anyone else talking about it.  So, in an effort to help some other poor sap like me out&#8230;</p>
<p>If you receive this error in <a href="http://easymock.org/">EasyMock</a> 2.3</p>
<pre>
java.lang.NoSuchMethodError: org.easymock.internal.RecordState.<init>(Lorg/easymock/internal/IMocksBehavior;)V
	at org.easymock.internal.MocksControl.reset(MocksControl.java:62)
	at org.easymock.internal.MocksControl.<init>(MocksControl.java:26)
	at org.easymock.classextension.internal.MocksClassControl.<init>(MocksClassControl.java:19)
	at org.easymock.classextension.EasyMock.createControl(EasyMock.java:108)
	at org.easymock.classextension.EasyMock.createMock(EasyMock.java:46)
</pre>
<p>It is most likely because you have an older version of EasyMock in your classpath.  In my case a referencing eclipse project had it, and in my project &#8220;order and export&#8221; tab I had the Project Higher on the Export list than the new version of EasyMock.  the easy way to fix this is just bump the newer EasyMock jars ahead of the older ones, or remove the older jars.</p>
]]></content:encoded>
			<wfw:commentRss>http://danielroop.com/blog/2008/05/22/easymock-exception-when-calling-createmock/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>What makes a great developer?</title>
		<link>http://danielroop.com/blog/2008/05/09/what-makes-a-great-developer/</link>
		<comments>http://danielroop.com/blog/2008/05/09/what-makes-a-great-developer/#comments</comments>
		<pubDate>Fri, 09 May 2008 12:05:34 +0000</pubDate>
		<dc:creator>Daniel Roop</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[rant]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[career]]></category>
		<category><![CDATA[passion]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://danielroop.com/blog/2008/05/09/what-makes-a-great-developer/</guid>
		<description><![CDATA[Passion. I have come to the conclusion that, that simple word is what separates an average developer from a great developer. IQ, education, degree, books, none of that matters, these are all symptoms of passion. A passionate developer will use &#8230; <a href="http://danielroop.com/blog/2008/05/09/what-makes-a-great-developer/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Passion.  I have come to the conclusion that, that simple word is what separates an average developer from a great developer.  IQ, education, degree, books, none of that matters, these are all symptoms of passion.  A passionate developer will use these tools to find answers and refine his/her craft, so they are good indicators of a great developer, but not quantifiers.  </p>
<p>A great developer takes ownership of his product, even if he doesn&#8217;t believe in the product.  That person will most likely pour their life and soul into their current assignment.  Typically you will find this person spending hours of their own researching and visiting user groups to enhance their skills. Some might even stop shaving facial hair in order to show their dedication to a particular assignment.</p>
<p>Should this be expected of all developers?  No!  Not everyone needs to have that level of passion for a project, but the chef needs it.  I love the show Hell&#8217;s Kitchen and you can tell Gordon Ramsey takes a passion in what he does.  Because of that passion he drives his potential employees to become better Chefs.  This effect is exactly why the team leader needs to have this passion.  </p>
<p>Time does not give you this passion, so in my opinion it doesn&#8217;t make sense to have the longest running employee be given top developer ranking.  Sometimes age can push you in the opposite direction, and you no longer care about the right things anymore.  Instead you care about trivial things like your dog, or your kids soccer game, or your birthday, or the big kicker sleep! I jest.</p>
<p>Why is passion so important?  Is it because with time you care less?  Not really.  I believe this industry is extremely exhausting.  Every time you turn around there is a new hot trend, and unless you are on it, you are so last minute!  That is easy enough to remedy, just don&#8217;t get on the new train, then you don&#8217;t need the passion.  The problem with that is that the industry is so young, if you don&#8217;t stay on the train you will probably be creating more work for yourself by following old practices that are more time consuming.  This isn&#8217;t a problem in more established fields like Architecture (of the wood/cement type), or Dentistry (of the teeth type), because&#8230;they are established.  These professions have been refined over hundreds if not thousands of years of the human experience.  What?  I don&#8217;t believe that statement myself, but think about it. Architecture has been around for literally thousands of years.  Humans have had an extremely long amount of time to find out what works and what doesn&#8217;t.  Programming has been around for 20+?  There is a big difference there.</p>
<p>There is another aspect to the passion.  Even after we have refined our craft to the point where it isn&#8217;t changing every 5 seconds, we will still need passionate developers.  That is because programming is only about 20% of what we actually do for the organization we are apart of.  We, developers, are responsible for building systems that satisfy business needs.  There is no one size fits all here, we have to understand what the business needs in order to build it.  That is what I love about what I do, because with every new job I can completely switch my entire industry, but be doing the same thing.  So if I get bored with the travel industry, I can switch back to the financial industry, or I can switch to the military industry.  But the flip side of that is I have to be passionate enough to invest the time and energy into understanding the business as my users understand the business.  Otherwise you won&#8217;t be able to produce the highest quality product.</p>
<p>I imagine this is why 37Signals is so successful.  They always talk about building applications for themselves.  This is an easy way out, this allows them to bypass the second part of the passion, because they are the users, so they already understand what they want.  This is not a bad approach, but everyone can&#8217;t do this.  Could you imagine if doctors or lawyers had to write their own software, they would have to spend an additional 4+ years in school on top of their already 8+ years.  They wouldn&#8217;t ever get anything done.  I am not knocking 37Signals, I am just suggesting everyone can&#8217;t build software for themselves.  Especially since it takes a certain mind to wrap around software engineering and it is rare to find a master of two trades that would be able to do this for every industry (not impossible, just improbable).</p>
<p>So what does it all mean?  I believe it means that it doesn&#8217;t matter how fast you code, or how many patterns you know, but it is about the fact that you care about what you are doing.  That probably seems obvious, but I personally find it extremely enlightening.  Whenever I write a piece of code I think about why I did it, and ask if there is a better way.  I don&#8217;t become attached to code, so when I learn a new technique I am not afraid to rewrite old code. I don&#8217;t see writing code as my job, I see building solutions to business problems as my job.  The work is in figuring out what to build and how to build it, not the code that is making it happen.  </p>
<p>This may be a bit presumptuous but I believe that is the difference between a great developer and an average developer.  A great developer helps build solutions to business problems and needs, and an average developer just takes orders and writes code. All the work is in working with the business to figure out what they want and how to do it, to a great developer writing code is like polishing the hardwood floors, it is the cherry on top of the perfect ice cream sundae.</p>
]]></content:encoded>
			<wfw:commentRss>http://danielroop.com/blog/2008/05/09/what-makes-a-great-developer/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>JRuby, Ruby gem command conflict</title>
		<link>http://danielroop.com/blog/2008/04/18/jruby-ruby-gem-command-conflict/</link>
		<comments>http://danielroop.com/blog/2008/04/18/jruby-ruby-gem-command-conflict/#comments</comments>
		<pubDate>Fri, 18 Apr 2008 19:38:58 +0000</pubDate>
		<dc:creator>Daniel Roop</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[languages]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[bsh]]></category>
		<category><![CDATA[gem]]></category>
		<category><![CDATA[ide]]></category>
		<category><![CDATA[jruby]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[path]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[symlink]]></category>

		<guid isPermaLink="false">http://danielroop.com/blog/2008/04/18/jruby-ruby-gem-command-conflict/</guid>
		<description><![CDATA[I would have to assume that there are plenty of developers out there that want to install JRuby and Ruby on the same machine. There is a tragic flaw with this, the gem command is the same for both. If &#8230; <a href="http://danielroop.com/blog/2008/04/18/jruby-ruby-gem-command-conflict/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I would have to assume that there are plenty of developers out there that want to install JRuby and Ruby on the same machine.  There is a tragic flaw with this, the gem command is the same for both. If you add both to the path there is no way to distinguish between the two version, so by default the most recent gem command included on the path will be used.  I have come up with a solution that I am happy with to solve this problem so I thought I would share it with the world.</p>
<p>First I am on a Mac, but this should work on any *nix based system.  Also I am using bsh, so if you use a different shell make sure to adjust the setting for that shell.</p>
<p>The process is quite simple, download/install Ruby and JRuby.  There are numerous tutorials for getting Ruby installed I would recommend the <a href="http://hivelogic.com/articles/2005/12/ruby_rails_lighttpd_mysql_tiger">install guide </a>put out by Dan Benjamin at Hive logic.  I typically tweak Dan&#8217;s tutorials and put my binaries in their own directory.  So instead of </p>
<pre>
/usr/local
</pre>
<p>I would install the binaries to </p>
<pre>
/usr/local/ruby/ruby-1.8.4
</pre>
<p>Then I would make a symlink from /usr/local/ruby/current to the most recent binary.  </p>
<pre>
cd /usr/local/ruby
ln -s /usr/local/ruby/ruby-1.8.4 current
</pre>
<p>And add /usr/local/ruby/current to my path.</p>
<pre>
RUBY_PATH="/usr/local/ruby/current"
export RUBY_PATH
PATH="${RUBY_PATH}/bin:${PATH}"
export PATH
</pre>
<p>I would typically add these lines to my ~/.bash_profile script to be executed whenever my shell starts.</p>
<p>All is fine and dandy until I install JRuby.  To install JRuby simply <a href="http://dist.codehaus.org/jruby/">download</a> the latest flavor. JRuby 1.1 was just released so I will use that as my example. Unpack the tar into /usr/local/jruby/jruby-1.1.  Now repeat the step above for creating a symlink to /usr/local/jruby/current.</p>
<pre>
cd /usr/local/jruby
ln -s /usr/local/jruby/jruby-1.1 current
</pre>
<p>Now here is the first tricky part.  Because I want ruby to be my default command line ruby executable I don&#8217;t want to add JRuby to the path. I do however, add the JRUBY_HOME environment variable.  To do this simply add the following lines to your <em>~/.bash_profile</em> script.</p>
<pre>
JRUBY_HOME="/usr/local/jruby/current"
export JRUBY_HOME
</pre>
<p>Now I need to create a way to add JRuby to the path as I need it. To do this I created a script and placed it in a folder located in my User folder </p>
<pre>~/Scripts</pre>
<p>I named the script <em>load_jruby</em> but you could name the file whatever you like. In the file I placed the following contents</p>
<pre>
PATH="${JRUBY_HOME}/bin:${PATH}"
export PATH
</pre>
<p>The final piece to the equation is called <em>sourcing the script</em>.  This basically means you want to run the script in the current process.  You need to do this because by default when you execute a script from the command line it spawns a new thread and any environment variables you change would only be affected inside of that script.  To source the script you simply prefix the command with a &#8220;.&#8221;.  So instead of</p>
<pre>
~/Scripts/load_jruby
</pre>
<p>you would type</p>
<pre>
. ~/Scripts/load_jruby
</pre>
<p>Now if you type </p>
<pre>
jruby --version
</pre>
<p>You should get output describing the version of JRuby you are running.</p>
<p>Obviously if you would prefer to have JRuby be your default Ruby installation just reverse the instructions.  Also this will not affect any defaults inside of IDEs like Aptana, so make sure you set those up for their respective environments.</p>
<p>There you have it, you can now have Ruby and JRuby installed on the same machine and work with them independently from the command line.  Whenever you want to work with Ruby open a new terminal and start typing.  If you want to work with JRuby open a new terminal and run your script to start rocking the JRuby.</p>
]]></content:encoded>
			<wfw:commentRss>http://danielroop.com/blog/2008/04/18/jruby-ruby-gem-command-conflict/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Aptana RadRails 1.0</title>
		<link>http://danielroop.com/blog/2008/03/12/aptana-radrails-10/</link>
		<comments>http://danielroop.com/blog/2008/03/12/aptana-radrails-10/#comments</comments>
		<pubDate>Wed, 12 Mar 2008 23:41:13 +0000</pubDate>
		<dc:creator>Daniel Roop</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[ide]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[radrails]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[textmate]]></category>

		<guid isPermaLink="false">http://danielroop.com/blog/2008/03/12/aptana-radrails-10/</guid>
		<description><![CDATA[I have recently become frustrated with the Eclipse IDE. I use 3.2 to do my java development, Flex Builder to do Flex development and Aptana RadRails for Ruby and Rails stuff. This last week I almost cracked and purchased TextMate &#8230; <a href="http://danielroop.com/blog/2008/03/12/aptana-radrails-10/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I have recently become frustrated with the Eclipse IDE.  I use 3.2 to do my java development, Flex Builder to do Flex development and Aptana RadRails for Ruby and Rails stuff.  This last week I almost cracked and purchased <a href="http://macromates.com/"> TextMate </a>, to see what all the fuss was, but since <a href="http://www.aptana.com/view/blog_front_page#/node/320">Aptana just released 1.0</a> of their RadRails plugin I figured I would give them a little more time.</p>
<p>I don&#8217;t tend to use most of the IDE features, highlighting and formatting are the big things for me, but code insight is always a plus.  I will give RadRails a few weeks, or until another great bundle that makes TextMate super cheap and make my decision then.</p>
]]></content:encoded>
			<wfw:commentRss>http://danielroop.com/blog/2008/03/12/aptana-radrails-10/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>2nd Player Revived</title>
		<link>http://danielroop.com/blog/2008/03/05/2nd-player-revived/</link>
		<comments>http://danielroop.com/blog/2008/03/05/2nd-player-revived/#comments</comments>
		<pubDate>Thu, 06 Mar 2008 01:03:40 +0000</pubDate>
		<dc:creator>Daniel Roop</dc:creator>
				<category><![CDATA[gaming]]></category>
		<category><![CDATA[project]]></category>
		<category><![CDATA[2ndPlayer]]></category>
		<category><![CDATA[podcast]]></category>

		<guid isPermaLink="false">http://danielroop.com/blog/2008/03/05/2nd-player-revived/</guid>
		<description><![CDATA[Michael, Bucky and I have cranked out another 2nd Player Episode. We cover where we have been, and plans we have for the site and podcast. We are not sure if we are going to stick with the bi-weekly schedule &#8230; <a href="http://danielroop.com/blog/2008/03/05/2nd-player-revived/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Michael, Bucky and I have cranked out another <a href="http://2ndplayer.net/2008/03/05/episode-7-stop-and-pop/">2nd Player Episode</a>.  We cover where we have been, and plans we have for the site and podcast.  We are not sure if we are going to stick with the bi-weekly schedule we had before, but we are going to attempt to be more regular than we have been recent.  Any comments are welcome as always, thanks for listening.</p>
]]></content:encoded>
			<wfw:commentRss>http://danielroop.com/blog/2008/03/05/2nd-player-revived/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>New Layout and Great T-Shirt</title>
		<link>http://danielroop.com/blog/2008/02/20/new-layout-and-great-t-shirt/</link>
		<comments>http://danielroop.com/blog/2008/02/20/new-layout-and-great-t-shirt/#comments</comments>
		<pubDate>Thu, 21 Feb 2008 03:11:40 +0000</pubDate>
		<dc:creator>Daniel Roop</dc:creator>
				<category><![CDATA[software]]></category>
		<category><![CDATA[layout]]></category>
		<category><![CDATA[rss]]></category>
		<category><![CDATA[tallyhoh]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://danielroop.com/blog/2008/02/20/new-layout-and-great-t-shirt/</guid>
		<description><![CDATA[For some reason, I decided to upgrade WordPress to 2.3.3 tonight. In the process I decided my layout was a little dated, so I updated that too. As an added bonus, the RSS Widget began working, I guess it didn&#8217;t &#8230; <a href="http://danielroop.com/blog/2008/02/20/new-layout-and-great-t-shirt/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>For some reason, I decided to upgrade WordPress to 2.3.3 tonight.  In the process I decided my layout was a little dated, so I updated that too.  As an added bonus, the RSS Widget began working, I guess it didn&#8217;t work on the old WordPress engine for some reason.</p>
<p>I even took the time to tweak the layout a little to include tags and categories, as well as updated the header image to be one of my own.  You are looking (if you are on my site and not reading this in your rss reader) at Lake Eola at Downtown Orlando.</p>
<p>In completely unrelated news, I put together an <a href="http://www.cafepress.com/danielroop.230662363">Infant T-Shirt</a> for my son at <a href="http://www.cafepress.com/danielroop">CafePress</a> in honor of TallyHoh launching.</p>
]]></content:encoded>
			<wfw:commentRss>http://danielroop.com/blog/2008/02/20/new-layout-and-great-t-shirt/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

