<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   >
<channel>
    <title>CaptRespect's Blog - Java Stuff</title>
    <link>http://captrespect.com/myblog/</link>
    <description>Life and Times of CaptRespect</description>
    <dc:language>en</dc:language>
    <generator>Serendipity 1.0.4 - http://www.s9y.org/</generator>
    <pubDate>Thu, 20 Sep 2007 02:07:21 GMT</pubDate>

    <image>
        <url>http://captrespect.com/myblog/templates/competition/img/s9y_banner_small.png</url>
        <title>RSS: CaptRespect's Blog - Java Stuff - Life and Times of CaptRespect</title>
        <link>http://captrespect.com/myblog/</link>
        <width>100</width>
        <height>21</height>
    </image>

<item>
    <title>Avoiding Overusing Java Interfaces</title>
    <link>http://captrespect.com/myblog/archives/8-Avoiding-Overusing-Java-Interfaces.html</link>
            <category>Java Stuff</category>
    
    <comments>http://captrespect.com/myblog/archives/8-Avoiding-Overusing-Java-Interfaces.html#comments</comments>
    <wfw:comment>http://captrespect.com/myblog/wfwcomment.php?cid=8</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://captrespect.com/myblog/rss.php?version=2.0&amp;type=comments&amp;cid=8</wfw:commentRss>
    

    <author>nospam@example.com (Jonathon Roberts)</author>
    <content:encoded>
    Everyone knows that a good interface is a good thing for a Java program.  Interfaces help keep your program flexible and loosely coupled while also enforcing a solid contract between your objects.&lt;br /&gt;
&lt;br /&gt;
But like everything else, too many interfaces are too much of a good thing.  Abusing interfaces makes your code hard to follow.  There can be too much code hiding, it becomes a burden to have to remember which implementation of your interface is being used.  You can get to an explosion of files due to each class having an interface defined.  This is one mistake I&#039;ve been making lately.  It&#039;s time to define some guidelines:&lt;br /&gt;
&lt;br /&gt;
1.  Don&#039;t use &quot;Impl&quot; in the class name.  &lt;br /&gt;
&lt;br /&gt;
If you can&#039;t think of a good descriptive name for your interface, maybe you shouldn&#039;t be defining it.  I&#039;ve found that for each class I have named MyInterfaceImpl I only ever have one implementation and that it probably would never make sense to have another implementation.  Later on, if you do create a new implementation, a good name will probably also reveal itself.  Refactoring to use the new interface is pretty straight forward.&lt;br /&gt;
&lt;br /&gt;
2.  If your interfaces keep changing, maybe you&#039;re better off without it. &lt;br /&gt;
&lt;br /&gt;
An interface that is constantly changing may indicate that it is too fine grained.  Maybe you can change that interface to use more general terms, or maybe you want to ditch it completely till it reveilles itself later.&lt;br /&gt;
&lt;br /&gt;
3.  Keep the interfaces small.&lt;br /&gt;
&lt;br /&gt;
Noone wants to mock your 50+ method interface.  (Yes, I&#039;m looking at you ResultSet)  Your interface should fit on an index card.  If it can&#039;t, ask if you really need it.  Is it too fine grained? Can you generalize it or break it up?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Dispite all this, remember that interfaces are still your friend.  If you can cleanly define one, by all means do it.  Just don&#039;t over do it.&lt;br /&gt;
&lt;br /&gt;
 
    </content:encoded>

    <pubDate>Wed, 19 Sep 2007 19:07:21 -0700</pubDate>
    <guid isPermaLink="false">http://captrespect.com/myblog/archives/8-guid.html</guid>
    
</item>
<item>
    <title>Java Package Naming Conventions</title>
    <link>http://captrespect.com/myblog/archives/5-Java-Package-Naming-Conventions.html</link>
            <category>Java Stuff</category>
    
    <comments>http://captrespect.com/myblog/archives/5-Java-Package-Naming-Conventions.html#comments</comments>
    <wfw:comment>http://captrespect.com/myblog/wfwcomment.php?cid=5</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://captrespect.com/myblog/rss.php?version=2.0&amp;type=comments&amp;cid=5</wfw:commentRss>
    

    <author>nospam@example.com (Jonathon Roberts)</author>
    <content:encoded>
    Naming your packages in Java seems pretty straight forward, but by changing your naming conventions a little you can track your dependencies a lot better.&lt;br /&gt;
&lt;br /&gt;
The usual standard for a package name seems to be url.application.module&lt;br /&gt;
So something like :  com.captrespect.roxorapp.dao&lt;br /&gt;
&lt;br /&gt;
But what happens when the same class can be used in different applications and is not application specific?  How do you tell which classes are specific to your app and which are not?&lt;br /&gt;
It may be best to not violate the DRY (Don&#039;t repeat yourself) principal and go the trouble of packaging all my potential common classes into a common jar.  A good programmer will eventually refactor the code down to this if need be.  But this is not trivial work, you&#039;ve got an app to finish, and you aren&#039;t even sure if the class is going to be used in other applications at all.  (But want to leave the option open)&lt;br /&gt;
&lt;br /&gt;
Say for example, com.captrespect.roxorapp.dao has two classes in it:&lt;br /&gt;
&lt;br /&gt;
RoxorDAO.java &lt;br /&gt;
QueryExecuter.java&lt;br /&gt;
&lt;br /&gt;
RoxorDAO will use the generic class QueryExecuter to run the queries.  QueryExecuter has nothing to do with RoxorApp and is a candidate for one day being refactored into a common jar.&lt;br /&gt;
&lt;br /&gt;
To be able tell this at a glance, change your package naming conventions a little.  So you would have&lt;br /&gt;
&lt;br /&gt;
com.captrespect.dao.QueryExecuter  and  &lt;br /&gt;
com.captrespect.roxorapp.dao.RoxorDAO&lt;br /&gt;
&lt;br /&gt;
Just because the source of the QueryExecuter is in your application, doesn&#039;t mean that you should name it that way.&lt;br /&gt;
This has minimal impact on your application while making it easy move the QueryExecuter into a separate common jar all without having to rename the package and make edits to all your dao&#039;s later.&lt;br /&gt;
&lt;br /&gt;
Of course there is always a downside,  mainly with logging.  &lt;br /&gt;
If you are using log4j, you won&#039;t be able to configure the logger for the whole app with just one line: com.captrepsect.roxorapp=DEBUG&lt;br /&gt;
This will come into play when you have more than one application deployed on the same server.&lt;br /&gt;
But I see this as a limitation with the logger, and the benefits outweigh the cost of a few extra lines in your log4j.properties file. &lt;br /&gt;
 
    </content:encoded>

    <pubDate>Tue, 04 Sep 2007 21:05:13 -0700</pubDate>
    <guid isPermaLink="false">http://captrespect.com/myblog/archives/5-guid.html</guid>
    
</item>
<item>
    <title>GET Parameters in JSF</title>
    <link>http://captrespect.com/myblog/archives/3-GET-Parameters-in-JSF.html</link>
            <category>Java Stuff</category>
    
    <comments>http://captrespect.com/myblog/archives/3-GET-Parameters-in-JSF.html#comments</comments>
    <wfw:comment>http://captrespect.com/myblog/wfwcomment.php?cid=3</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://captrespect.com/myblog/rss.php?version=2.0&amp;type=comments&amp;cid=3</wfw:commentRss>
    

    <author>nospam@example.com (Jonathon Roberts)</author>
    <content:encoded>
    We recently started a new project at work.  The web application was going to be started by linking from another page.  The links were going to look a little something like this:&lt;br /&gt;
&lt;br /&gt;
http://mysuperapp.com/appname?mygetparam=program1&lt;br /&gt;
http://mysuperapp.com/appname?mygetparam=program2&lt;br /&gt;
http://mysuperapp.com/appname?mygetparam=program3&lt;br /&gt;
&lt;br /&gt;
A few weeks before I remembered reading about how hard is was to use GET parameters in a JSF application.  So a red flag went up in my head, and I did a little research.  A bunch of sites told me that is hard to get your components to send requests via GET parameters, but it turns out it&#039;s actually easy to bind GET parameters to your backing bean. (Just putting them in the url is cludgy)&lt;br /&gt;
&lt;br /&gt;
All you have to do is use the param object in your el expression:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;managed-bean&amp;gt;&lt;br /&gt;
    &amp;lt;managed-bean-name&amp;gt;myBean&amp;lt;/managed-bean-name&amp;gt;&lt;br /&gt;
    &amp;lt;managed-bean-class&amp;gt;com.mysuperapp.MyBean&amp;lt;/managed-bean-class&amp;gt;&lt;br /&gt;
    &amp;lt;managed-bean-scope&amp;gt;request&amp;lt;/managed-bean-scope&amp;gt;&lt;br /&gt;
    &amp;lt;managed-property&amp;gt;&lt;br /&gt;
      &amp;lt;property-name&amp;gt;myPropery&amp;lt;/property-name&amp;gt;&lt;br /&gt;
      &amp;lt;value&amp;gt;#{param.mygetparam}&amp;lt;/value&amp;gt;&lt;br /&gt;
    &amp;lt;/managed-property&amp;gt;&lt;br /&gt;
  &amp;lt;/managed-bean&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now your request scope backing bean has the value from the url.  &lt;br /&gt;
&lt;br /&gt;
Easy.&lt;br /&gt;
 
    </content:encoded>

    <pubDate>Tue, 07 Aug 2007 17:38:37 -0700</pubDate>
    <guid isPermaLink="false">http://captrespect.com/myblog/archives/3-guid.html</guid>
    
</item>

</channel>
</rss>