<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Java Class Naming Conventions</title>
	<atom:link href="http://leshazlewood.com/2009/03/03/java-class-naming-conventions/feed/" rel="self" type="application/rss+xml" />
	<link>http://leshazlewood.com/2009/03/03/java-class-naming-conventions/</link>
	<description>Where Les is More</description>
	<lastBuildDate>Thu, 26 Apr 2012 02:41:36 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: Max</title>
		<link>http://leshazlewood.com/2009/03/03/java-class-naming-conventions/comment-page-1/#comment-521</link>
		<dc:creator>Max</dc:creator>
		<pubDate>Sun, 06 Jun 2010 18:58:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.leshazlewood.com/?p=49#comment-521</guid>
		<description>@Pedro, I assume that your DefaultClassNameStrategy is an interface and DefaultDefaultClassNameStrategy is a concrete class. In this case having DefaultClassNameStrategy as an interface is not a good idea. Instead I would have a Strategy interface that defines common behaviour for all strategies and have DefaultClassNameStrategy as a Strategy implementation for DefaultClassName class.
For example,

interface Sort
class DefaultSort

interface Strategy
class DefaultSortStrategy

Max.</description>
		<content:encoded><![CDATA[<p>@Pedro, I assume that your DefaultClassNameStrategy is an interface and DefaultDefaultClassNameStrategy is a concrete class. In this case having DefaultClassNameStrategy as an interface is not a good idea. Instead I would have a Strategy interface that defines common behaviour for all strategies and have DefaultClassNameStrategy as a Strategy implementation for DefaultClassName class.<br />
For example,</p>
<p>interface Sort<br />
class DefaultSort</p>
<p>interface Strategy<br />
class DefaultSortStrategy</p>
<p>Max.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pedro</title>
		<link>http://leshazlewood.com/2009/03/03/java-class-naming-conventions/comment-page-1/#comment-485</link>
		<dc:creator>Pedro</dc:creator>
		<pubDate>Mon, 26 Apr 2010 22:06:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.leshazlewood.com/?p=49#comment-485</guid>
		<description>Hi. I ran into a situation that I&#039;m puzzled.

I have an Interface: ClassName
I have a default impl: &lt;i&gt;Defaut&lt;/i&gt;ClassName
I have an strategy for this impl: &lt;i&gt;Default&lt;/i&gt;ClassName&lt;i&gt;Strategy&lt;/i&gt;
Now I default impl for this strategy: &lt;i&gt;Default&lt;/i&gt;&lt;i&gt;Default&lt;i&gt;ClassName&lt;i&gt;Strategy&lt;/i&gt;

???

I believe that  the strategy is very specific for the &lt;i&gt;Defaut&lt;/i&gt;ClassName, other implementations of ClassName would not, might not use the same strategy.
Therefore I believe that the strategy should be attached to an implementation rather than generic interface...

But I can see people complaining in my team: Default&lt;i&gt;Default&lt;/i&gt;...???

Suggestions?</description>
		<content:encoded><![CDATA[<p>Hi. I ran into a situation that I&#8217;m puzzled.</p>
<p>I have an Interface: ClassName<br />
I have a default impl: <i>Defaut</i>ClassName<br />
I have an strategy for this impl: <i>Default</i>ClassName<i>Strategy</i><br />
Now I default impl for this strategy: <i>Default</i><i>Default</i><i>ClassName</i><i>Strategy</i></p>
<p>???</p>
<p>I believe that  the strategy is very specific for the <i>Defaut</i>ClassName, other implementations of ClassName would not, might not use the same strategy.<br />
Therefore I believe that the strategy should be attached to an implementation rather than generic interface&#8230;</p>
<p>But I can see people complaining in my team: Default<i>Default</i>&#8230;???</p>
<p>Suggestions?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Make Me Admin So I Can Fix Your Problems - Page 849 - Tech Central Forums</title>
		<link>http://leshazlewood.com/2009/03/03/java-class-naming-conventions/comment-page-1/#comment-484</link>
		<dc:creator>Make Me Admin So I Can Fix Your Problems - Page 849 - Tech Central Forums</dc:creator>
		<pubDate>Tue, 02 Feb 2010 06:44:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.leshazlewood.com/?p=49#comment-484</guid>
		<description>[...] link - article link - article link - article link - article link - article link - article link - article link - article link - article link - article link - article link - article link - article link - article [...]</description>
		<content:encoded><![CDATA[<p>[...] link &#8211; article link &#8211; article link &#8211; article link &#8211; article link &#8211; article link &#8211; article link &#8211; article link &#8211; article link &#8211; article link &#8211; article link &#8211; article link &#8211; article link &#8211; article link &#8211; article [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Important matters in web design - Davao FOSS Forums</title>
		<link>http://leshazlewood.com/2009/03/03/java-class-naming-conventions/comment-page-1/#comment-483</link>
		<dc:creator>Important matters in web design - Davao FOSS Forums</dc:creator>
		<pubDate>Tue, 02 Feb 2010 06:04:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.leshazlewood.com/?p=49#comment-483</guid>
		<description>[...] link - article link - article link - article link - article link - article link - article link - article link - article link - article link - article link - article link - article link - article link - article [...]</description>
		<content:encoded><![CDATA[<p>[...] link &#8211; article link &#8211; article link &#8211; article link &#8211; article link &#8211; article link &#8211; article link &#8211; article link &#8211; article link &#8211; article link &#8211; article link &#8211; article link &#8211; article link &#8211; article link &#8211; article [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Great forum - Page 16 - Conceive Forums</title>
		<link>http://leshazlewood.com/2009/03/03/java-class-naming-conventions/comment-page-1/#comment-482</link>
		<dc:creator>Great forum - Page 16 - Conceive Forums</dc:creator>
		<pubDate>Tue, 02 Feb 2010 04:12:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.leshazlewood.com/?p=49#comment-482</guid>
		<description>[...] link - article link - article link - article link - article link - article link - article link - article link - article link - article link - article link - article link - article link - article link - article [...]</description>
		<content:encoded><![CDATA[<p>[...] link &#8211; article link &#8211; article link &#8211; article link &#8211; article link &#8211; article link &#8211; article link &#8211; article link &#8211; article link &#8211; article link &#8211; article link &#8211; article link &#8211; article link &#8211; article link &#8211; article [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Les</title>
		<link>http://leshazlewood.com/2009/03/03/java-class-naming-conventions/comment-page-1/#comment-481</link>
		<dc:creator>Les</dc:creator>
		<pubDate>Wed, 09 Dec 2009 19:46:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.leshazlewood.com/?p=49#comment-481</guid>
		<description>@John

I&#039;ll guess we&#039;ll have to disagree a little :)  I believe that distinguishing implementation strategies by a package name alone is an inconvenient solution.  When you&#039;re looking at source code in a file, and see a &lt;code&gt;UserDaoImpl&lt;/code&gt; reference, when was the last time you looked at an instance&#039;s fully qualified class name to understand why it exists?  I personally wouldn&#039;t want to do this.

Also, most OO conventions prefix more specific information to the class name - not suffix it (e.g. *Impl), for good reasons that correspond to natural language tendencies and make code easier to read.

That is, HibernatUserDao, JpaUserDao, CachingUserDao, etc are all easier to read and easily distinguishable compared to UserDaoImpl.  Referring to a fully qualified package name to easily identify the implementation purpose is not as nice IMO.

I&#039;ve also found that segmenting package names based on core application concepts (&lt;code&gt;com.company.remoting.*&lt;/code&gt;, &lt;code&gt;com.company.messaging.*&lt;/code&gt;, etc.) instead of implementation technologies is more resilient to change over time.  Libraries come and go, but an application&#039;s data model and core architectural concepts change the least frequently.  This translates into a fairly stable source tree that doesn&#039;t have to be refactored as often as one that doesn&#039;t employ these principles.  Moving packages, although easy enough with good IDEs, translates to many files touched during refactoring, and adds a lot of noise to change history, which in turn makes it more difficult to see the *real* impact of a change.  There are other repercussions too, but that kind of gives you a foundation for my reasoning.

My recommendation is to always keep OO naming clean and consistent - if one uses the prefix convention for Strategy implementations, IMO there is no good reason not to use the same convention for all classes.  I think it is confusing to mix naming conventions across the code base.

The best advice I have for anyone writing implementations are my following &quot;Golden 3&quot; OO naming rules:

1. Classes are always nouns.  No exceptions.
2. Methods are verbs or verb clauses.  No exceptions.
3. Interface implementations or subclasses prefix their implemented interface name or parent class name, adhering to natural language principles and being able to immediately understand the class&#039;s purpose. (UserDao -&gt; HibernateUserDao, JdbcUserDao, etc).

Cheers,

Les</description>
		<content:encoded><![CDATA[<p>@John</p>
<p>I&#8217;ll guess we&#8217;ll have to disagree a little <img src='http://leshazlewood.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   I believe that distinguishing implementation strategies by a package name alone is an inconvenient solution.  When you&#8217;re looking at source code in a file, and see a <code>UserDaoImpl</code> reference, when was the last time you looked at an instance&#8217;s fully qualified class name to understand why it exists?  I personally wouldn&#8217;t want to do this.</p>
<p>Also, most OO conventions prefix more specific information to the class name &#8211; not suffix it (e.g. *Impl), for good reasons that correspond to natural language tendencies and make code easier to read.</p>
<p>That is, HibernatUserDao, JpaUserDao, CachingUserDao, etc are all easier to read and easily distinguishable compared to UserDaoImpl.  Referring to a fully qualified package name to easily identify the implementation purpose is not as nice IMO.</p>
<p>I&#8217;ve also found that segmenting package names based on core application concepts (<code>com.company.remoting.*</code>, <code>com.company.messaging.*</code>, etc.) instead of implementation technologies is more resilient to change over time.  Libraries come and go, but an application&#8217;s data model and core architectural concepts change the least frequently.  This translates into a fairly stable source tree that doesn&#8217;t have to be refactored as often as one that doesn&#8217;t employ these principles.  Moving packages, although easy enough with good IDEs, translates to many files touched during refactoring, and adds a lot of noise to change history, which in turn makes it more difficult to see the *real* impact of a change.  There are other repercussions too, but that kind of gives you a foundation for my reasoning.</p>
<p>My recommendation is to always keep OO naming clean and consistent &#8211; if one uses the prefix convention for Strategy implementations, IMO there is no good reason not to use the same convention for all classes.  I think it is confusing to mix naming conventions across the code base.</p>
<p>The best advice I have for anyone writing implementations are my following &#8220;Golden 3&#8243; OO naming rules:</p>
<p>1. Classes are always nouns.  No exceptions.<br />
2. Methods are verbs or verb clauses.  No exceptions.<br />
3. Interface implementations or subclasses prefix their implemented interface name or parent class name, adhering to natural language principles and being able to immediately understand the class&#8217;s purpose. (UserDao -> HibernateUserDao, JdbcUserDao, etc).</p>
<p>Cheers,</p>
<p>Les</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Turner</title>
		<link>http://leshazlewood.com/2009/03/03/java-class-naming-conventions/comment-page-1/#comment-480</link>
		<dc:creator>John Turner</dc:creator>
		<pubDate>Wed, 09 Dec 2009 17:33:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.leshazlewood.com/?p=49#comment-480</guid>
		<description>I do agree to some extent but I tend to use a different package to group implementations.  For example, i might have a dao, dao\jpa, dao\hibernate package with classes named SomeDao, SomeDaoImpl, SomeDaoImpl.

For model objects I would tend to just use the ModelObject and ModelObjectImpl convention as there is really only every one implementation.

I also use the naming convention that you have outlined in other situations, for example naming Strategy implementations.

Overall, I would say all these naming conventions have merits.

John</description>
		<content:encoded><![CDATA[<p>I do agree to some extent but I tend to use a different package to group implementations.  For example, i might have a dao, dao\jpa, dao\hibernate package with classes named SomeDao, SomeDaoImpl, SomeDaoImpl.</p>
<p>For model objects I would tend to just use the ModelObject and ModelObjectImpl convention as there is really only every one implementation.</p>
<p>I also use the naming convention that you have outlined in other situations, for example naming Strategy implementations.</p>
<p>Overall, I would say all these naming conventions have merits.</p>
<p>John</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Willi</title>
		<link>http://leshazlewood.com/2009/03/03/java-class-naming-conventions/comment-page-1/#comment-479</link>
		<dc:creator>Willi</dc:creator>
		<pubDate>Thu, 24 Sep 2009 20:15:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.leshazlewood.com/?p=49#comment-479</guid>
		<description>I really hate that *Impl stuff in APIs and libraries, but i never found the perfect naming strategy. You did. Thanks. Your approach is way better.</description>
		<content:encoded><![CDATA[<p>I really hate that *Impl stuff in APIs and libraries, but i never found the perfect naming strategy. You did. Thanks. Your approach is way better.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

