<?xml version="1.0" encoding="utf-8"?><!-- generator="wordpress/2.0.2" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: A message to Sun engineers: Please stop making my code ugly</title>
	<link>http://joust.kano.net/weblog/archive/2005/08/30/a-message-to-sun-engineers-please-stop-making-my-code-ugly/</link>
	<description>A weblog for Keith Lea and the Joust Project.</description>
	<pubDate>Fri, 21 Nov 2008 05:11:12 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.2</generator>

	<item>
		<title>by: Bob Lee</title>
		<link>http://joust.kano.net/weblog/archive/2005/08/30/a-message-to-sun-engineers-please-stop-making-my-code-ugly/#comment-1660</link>
		<pubDate>Sat, 29 Oct 2005 14:21:18 +0000</pubDate>
		<guid>http://joust.kano.net/weblog/archive/2005/08/30/a-message-to-sun-engineers-please-stop-making-my-code-ugly/#comment-1660</guid>
					<description>Good words, Keith. Let's nip this in the bud: http://crazybob.org/2005/10/i-heart-getters-and-setters.html</description>
		<content:encoded><![CDATA[<p>Good words, Keith. Let&#8217;s nip this in the bud: <a href='http://crazybob.org/2005/10/i-heart-getters-and-setters.html' rel='nofollow'>http://crazybob.org/2005/10/i-heart-getters-and-setters.html</a>
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Dan</title>
		<link>http://joust.kano.net/weblog/archive/2005/08/30/a-message-to-sun-engineers-please-stop-making-my-code-ugly/#comment-1441</link>
		<pubDate>Fri, 02 Sep 2005 06:29:33 +0000</pubDate>
		<guid>http://joust.kano.net/weblog/archive/2005/08/30/a-message-to-sun-engineers-please-stop-making-my-code-ugly/#comment-1441</guid>
					<description>&amp;#62; Daniel Hinojosa:
&amp;#62;Hahaha! I agree. You donâ€™t know the squirming I have to do when I get asked, â€œIf &amp;#62;encapsulation is so important, why can you access length directly from any array? &amp;#62;and why doesnâ€™t it come with a getter and setterâ€?. :) 

Dont squirm just explain Arrays are stupid objects with no behaviour - just data.
</description>
		<content:encoded><![CDATA[<p>&gt; Daniel Hinojosa:<br />
&gt;Hahaha! I agree. You donâ€™t know the squirming I have to do when I get asked, â€œIf &gt;encapsulation is so important, why can you access length directly from any array? &gt;and why doesnâ€™t it come with a getter and setterâ€?. :) </p>
<p>Dont squirm just explain Arrays are stupid objects with no behaviour - just data.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Keith</title>
		<link>http://joust.kano.net/weblog/archive/2005/08/30/a-message-to-sun-engineers-please-stop-making-my-code-ugly/#comment-1434</link>
		<pubDate>Wed, 31 Aug 2005 15:16:46 +0000</pubDate>
		<guid>http://joust.kano.net/weblog/archive/2005/08/30/a-message-to-sun-engineers-please-stop-making-my-code-ugly/#comment-1434</guid>
					<description>Rob, it should be called createMatcher if it creates a matcher. I never said anything about an &quot;execute method.&quot; The method is &lt;code&gt;Executors.callable(Runnable)&lt;/code&gt; which simply creates a Callable instance which calls the Runnable and returns null, it doesn't execute anything.</description>
		<content:encoded><![CDATA[<p>Rob, it should be called createMatcher if it creates a matcher. I never said anything about an &#8220;execute method.&#8221; The method is <code>Executors.callable(Runnable)</code> which simply creates a Callable instance which calls the Runnable and returns null, it doesn&#8217;t execute anything.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Rob Sanheim</title>
		<link>http://joust.kano.net/weblog/archive/2005/08/30/a-message-to-sun-engineers-please-stop-making-my-code-ugly/#comment-1432</link>
		<pubDate>Wed, 31 Aug 2005 15:11:40 +0000</pubDate>
		<guid>http://joust.kano.net/weblog/archive/2005/08/30/a-message-to-sun-engineers-please-stop-making-my-code-ugly/#comment-1432</guid>
					<description>Typically you only want getters and setters to be very simple operations that do not change the object state beyond the attribute in question.  I think that is the reason things like the Pattern#matcher method is named as it is - the java doc says: &quot;Creates a matcher that will match the given input against this pattern.&quot; You really don't want something that takes a param and creates a new object to be called &quot;getMatcher&quot;.  Also, the execute method should definitely not be a getter or setter: &quot;Executes the given command at some time in the future. The command may execute in a new thread, in a pooled thread, or in the calling thread, at the discretion of the Executor implementation.&quot;  This is definitely not a case where you want something to be called setRunnable, as it is really doing a whole lot more work then just setting an attribute.

So following the JavaBean naming convetion makes sense on simple pojos, particularily ones that face your GUI, but methods that do then get/set more work should not follow the standard just to allow tools to work.
</description>
		<content:encoded><![CDATA[<p>Typically you only want getters and setters to be very simple operations that do not change the object state beyond the attribute in question.  I think that is the reason things like the Pattern#matcher method is named as it is - the java doc says: &#8220;Creates a matcher that will match the given input against this pattern.&#8221; You really don&#8217;t want something that takes a param and creates a new object to be called &#8220;getMatcher&#8221;.  Also, the execute method should definitely not be a getter or setter: &#8220;Executes the given command at some time in the future. The command may execute in a new thread, in a pooled thread, or in the calling thread, at the discretion of the Executor implementation.&#8221;  This is definitely not a case where you want something to be called setRunnable, as it is really doing a whole lot more work then just setting an attribute.</p>
<p>So following the JavaBean naming convetion makes sense on simple pojos, particularily ones that face your GUI, but methods that do then get/set more work should not follow the standard just to allow tools to work.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Keith</title>
		<link>http://joust.kano.net/weblog/archive/2005/08/30/a-message-to-sun-engineers-please-stop-making-my-code-ugly/#comment-1431</link>
		<pubDate>Wed, 31 Aug 2005 14:32:39 +0000</pubDate>
		<guid>http://joust.kano.net/weblog/archive/2005/08/30/a-message-to-sun-engineers-please-stop-making-my-code-ugly/#comment-1431</guid>
					<description>In response to comment #4, if they are operations, why are their method names nouns? Operations are expressed using verbs in English.</description>
		<content:encoded><![CDATA[<p>In response to comment #4, if they are operations, why are their method names nouns? Operations are expressed using verbs in English.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Behrang</title>
		<link>http://joust.kano.net/weblog/archive/2005/08/30/a-message-to-sun-engineers-please-stop-making-my-code-ugly/#comment-1430</link>
		<pubDate>Wed, 31 Aug 2005 09:15:06 +0000</pubDate>
		<guid>http://joust.kano.net/weblog/archive/2005/08/30/a-message-to-sun-engineers-please-stop-making-my-code-ugly/#comment-1430</guid>
					<description>Sumit,

The problem is that &quot;iterator&quot; and &quot;next&quot; are not &quot;properties&quot;. The is/get/set convention is only applicable to properties. Nevertheless, I also don't like seeing that built-in Java classes do not adhere to the naming conventions here and there. The first one I encountered was the Color.red, Color.green, ... static variables which had to be Color.RED (Sun fixed this in 1.4) Also the classes/interfaces in the CORBA related packages are entirely against the conventions :-)</description>
		<content:encoded><![CDATA[<p>Sumit,</p>
<p>The problem is that &#8220;iterator&#8221; and &#8220;next&#8221; are not &#8220;properties&#8221;. The is/get/set convention is only applicable to properties. Nevertheless, I also don&#8217;t like seeing that built-in Java classes do not adhere to the naming conventions here and there. The first one I encountered was the Color.red, Color.green, &#8230; static variables which had to be Color.RED (Sun fixed this in 1.4) Also the classes/interfaces in the CORBA related packages are entirely against the conventions :-)
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Anonymous</title>
		<link>http://joust.kano.net/weblog/archive/2005/08/30/a-message-to-sun-engineers-please-stop-making-my-code-ugly/#comment-1429</link>
		<pubDate>Wed, 31 Aug 2005 06:08:35 +0000</pubDate>
		<guid>http://joust.kano.net/weblog/archive/2005/08/30/a-message-to-sun-engineers-please-stop-making-my-code-ugly/#comment-1429</guid>
					<description>actually I believe in many (but not all) methods like that are operations in the strict sense and not properties which means they don't really have to follow the java beans standards.

also with BeanInfo classes - equally part of the spec - you don't have to use getX/setX for some property X anyway.</description>
		<content:encoded><![CDATA[<p>actually I believe in many (but not all) methods like that are operations in the strict sense and not properties which means they don&#8217;t really have to follow the java beans standards.</p>
<p>also with BeanInfo classes - equally part of the spec - you don&#8217;t have to use getX/setX for some property X anyway.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Charlie Hayes</title>
		<link>http://joust.kano.net/weblog/archive/2005/08/30/a-message-to-sun-engineers-please-stop-making-my-code-ugly/#comment-1428</link>
		<pubDate>Wed, 31 Aug 2005 01:12:26 +0000</pubDate>
		<guid>http://joust.kano.net/weblog/archive/2005/08/30/a-message-to-sun-engineers-please-stop-making-my-code-ugly/#comment-1428</guid>
					<description>I agree. It feels dirty setting public variables from outside a class. It doesn't feel quite as dirty to read them, although still somewhat dirty.</description>
		<content:encoded><![CDATA[<p>I agree. It feels dirty setting public variables from outside a class. It doesn&#8217;t feel quite as dirty to read them, although still somewhat dirty.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Daniel Hinojosa</title>
		<link>http://joust.kano.net/weblog/archive/2005/08/30/a-message-to-sun-engineers-please-stop-making-my-code-ugly/#comment-1427</link>
		<pubDate>Tue, 30 Aug 2005 21:40:14 +0000</pubDate>
		<guid>http://joust.kano.net/weblog/archive/2005/08/30/a-message-to-sun-engineers-please-stop-making-my-code-ugly/#comment-1427</guid>
					<description>Hahaha! I agree. You don't know the squirming I have to do when I get asked, &quot;If encapsulation is so important, why can you access length directly from any array? and why doesn't it come with a getter and setter&quot;.  :)  </description>
		<content:encoded><![CDATA[<p>Hahaha! I agree. You don&#8217;t know the squirming I have to do when I get asked, &#8220;If encapsulation is so important, why can you access length directly from any array? and why doesn&#8217;t it come with a getter and setter&#8221;.  :)
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Sumit</title>
		<link>http://joust.kano.net/weblog/archive/2005/08/30/a-message-to-sun-engineers-please-stop-making-my-code-ugly/#comment-1426</link>
		<pubDate>Tue, 30 Aug 2005 21:03:11 +0000</pubDate>
		<guid>http://joust.kano.net/weblog/archive/2005/08/30/a-message-to-sun-engineers-please-stop-making-my-code-ugly/#comment-1426</guid>
					<description>Josh Bloch also suggests in 'Effective Java' that in general following conventions like JavaBeans is a good idea, but in some general-use APIs which are expected to get heavy use, it's not a bad idea to make method names smaller. A typical case is teh Collections classes, which have methods like iterator() and next() rather than getIterator() and getNext(). After all, most likely somebody is typing these, and it's no fun writing long method names always.

Sumit.</description>
		<content:encoded><![CDATA[<p>Josh Bloch also suggests in &#8216;Effective Java&#8217; that in general following conventions like JavaBeans is a good idea, but in some general-use APIs which are expected to get heavy use, it&#8217;s not a bad idea to make method names smaller. A typical case is teh Collections classes, which have methods like iterator() and next() rather than getIterator() and getNext(). After all, most likely somebody is typing these, and it&#8217;s no fun writing long method names always.</p>
<p>Sumit.
</p>
]]></content:encoded>
				</item>
</channel>
</rss>
