<?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"
	>
<channel>
	<title>Comments on: Bending Java: More readable code with methods that do nothing?</title>
	<atom:link href="http://www.codemonkeyism.com/archives/2008/05/09/bending-java-more-readable-code-with-methods-that-do-nothing/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.codemonkeyism.com/archives/2008/05/09/bending-java-more-readable-code-with-methods-that-do-nothing/</link>
	<description>Programming is hard</description>
	<pubDate>Sat, 22 Nov 2008 13:13:38 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
		<item>
		<title>By: Dobes</title>
		<link>http://www.codemonkeyism.com/archives/2008/05/09/bending-java-more-readable-code-with-methods-that-do-nothing/#comment-115512</link>
		<dc:creator>Dobes</dc:creator>
		<pubDate>Mon, 23 Jun 2008 08:02:01 +0000</pubDate>
		<guid isPermaLink="false">http://stephan.reposita.org/archives/2008/05/09/bending-java-more-readable-code-with-methods-that-do-nothing/#comment-115512</guid>
		<description>I like Nick's solution, I don't think that renaming is that big of a deal in practice, even if it looks bad in theory.

I couldn't help but wonder whether Java 5 annotations would work for this somehow.</description>
		<content:encoded><![CDATA[<p>I like Nick&#8217;s solution, I don&#8217;t think that renaming is that big of a deal in practice, even if it looks bad in theory.</p>
<p>I couldn&#8217;t help but wonder whether Java 5 annotations would work for this somehow.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stephan</title>
		<link>http://www.codemonkeyism.com/archives/2008/05/09/bending-java-more-readable-code-with-methods-that-do-nothing/#comment-87742</link>
		<dc:creator>stephan</dc:creator>
		<pubDate>Mon, 12 May 2008 05:49:44 +0000</pubDate>
		<guid isPermaLink="false">http://stephan.reposita.org/archives/2008/05/09/bending-java-more-readable-code-with-methods-that-do-nothing/#comment-87742</guid>
		<description>@Andrea: As written before, the comments don't work with refactorings (yes I know some IDEs do refactor comments but this is very error prone). Changing the methods when changing the types probably is a good idea, because changing one information without the other makes code unreadable over time.</description>
		<content:encoded><![CDATA[<p>@Andrea: As written before, the comments don&#8217;t work with refactorings (yes I know some IDEs do refactor comments but this is very error prone). Changing the methods when changing the types probably is a good idea, because changing one information without the other makes code unreadable over time.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrea Francia</title>
		<link>http://www.codemonkeyism.com/archives/2008/05/09/bending-java-more-readable-code-with-methods-that-do-nothing/#comment-87617</link>
		<dc:creator>Andrea Francia</dc:creator>
		<pubDate>Sun, 11 May 2008 22:33:18 +0000</pubDate>
		<guid isPermaLink="false">http://stephan.reposita.org/archives/2008/05/09/bending-java-more-readable-code-with-methods-that-do-nothing/#comment-87617</guid>
		<description>I don't see the convenience of introducing methods (that should be maintained later) to achieve something that can be already achieved using the standard documentation tool of every language: comments.

Customer c =  new Customer( "John" /*firstname*/, 
                                           "Smith" /*lastname*/,
                                           87 /*age*/);

Introducing a method called firstname() or lastname() is so necessary?
When the type or the name of a property change you have to change also the method.

And what about the method name resolution? Using your method technique you have to import static all the methods do use it.

However I see a good thing of this idea. It can stimulate thinking about Java syntax and possible improvements to it.</description>
		<content:encoded><![CDATA[<p>I don&#8217;t see the convenience of introducing methods (that should be maintained later) to achieve something that can be already achieved using the standard documentation tool of every language: comments.</p>
<p>Customer c =  new Customer( &#8220;John&#8221; /*firstname*/,<br />
                                           &#8220;Smith&#8221; /*lastname*/,<br />
                                           87 /*age*/);</p>
<p>Introducing a method called firstname() or lastname() is so necessary?<br />
When the type or the name of a property change you have to change also the method.</p>
<p>And what about the method name resolution? Using your method technique you have to import static all the methods do use it.</p>
<p>However I see a good thing of this idea. It can stimulate thinking about Java syntax and possible improvements to it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stephan</title>
		<link>http://www.codemonkeyism.com/archives/2008/05/09/bending-java-more-readable-code-with-methods-that-do-nothing/#comment-87584</link>
		<dc:creator>stephan</dc:creator>
		<pubDate>Sun, 11 May 2008 18:21:12 +0000</pubDate>
		<guid isPermaLink="false">http://stephan.reposita.org/archives/2008/05/09/bending-java-more-readable-code-with-methods-that-do-nothing/#comment-87584</guid>
		<description>@Jan, raveman: Yes, see my post about fluent interface builders

@James: Yes, I like named parmeters

@Nick: Yes, this does work for small parameter lists, but breaks down for longer ones. It  also doesn't help with larger code bases where developers start to rename parameters. The difference between renaming &lt;code&gt;String name&lt;/code&gt; and &lt;code&gt;name()&lt;/code&gt; is that the first renaming is only local, the second is global and does therefor scale much better.

@Uri: Hmm, need to try that.

@Casper: Looks nice too.

I was using names parameters the first time during the 80 I guess with a programming language called E on the Amiga (or was it the 90s?). I like the idea since then, but Java regretfully doesn't have them.</description>
		<content:encoded><![CDATA[<p>@Jan, raveman: Yes, see my post about fluent interface builders</p>
<p>@James: Yes, I like named parmeters</p>
<p>@Nick: Yes, this does work for small parameter lists, but breaks down for longer ones. It  also doesn&#8217;t help with larger code bases where developers start to rename parameters. The difference between renaming <code>String name</code> and <code>name()</code> is that the first renaming is only local, the second is global and does therefor scale much better.</p>
<p>@Uri: Hmm, need to try that.</p>
<p>@Casper: Looks nice too.</p>
<p>I was using names parameters the first time during the 80 I guess with a programming language called E on the Amiga (or was it the 90s?). I like the idea since then, but Java regretfully doesn&#8217;t have them.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James Hughes</title>
		<link>http://www.codemonkeyism.com/archives/2008/05/09/bending-java-more-readable-code-with-methods-that-do-nothing/#comment-87477</link>
		<dc:creator>James Hughes</dc:creator>
		<pubDate>Sun, 11 May 2008 08:45:06 +0000</pubDate>
		<guid isPermaLink="false">http://stephan.reposita.org/archives/2008/05/09/bending-java-more-readable-code-with-methods-that-do-nothing/#comment-87477</guid>
		<description>Ammmm The naming convention is very similar to how Groovy would do - named arguments.

def cust = new Customer(name:"James")</description>
		<content:encoded><![CDATA[<p>Ammmm The naming convention is very similar to how Groovy would do - named arguments.</p>
<p>def cust = new Customer(name:&#8221;James&#8221;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Uri</title>
		<link>http://www.codemonkeyism.com/archives/2008/05/09/bending-java-more-readable-code-with-methods-that-do-nothing/#comment-87446</link>
		<dc:creator>Uri</dc:creator>
		<pubDate>Sun, 11 May 2008 04:06:19 +0000</pubDate>
		<guid isPermaLink="false">http://stephan.reposita.org/archives/2008/05/09/bending-java-more-readable-code-with-methods-that-do-nothing/#comment-87446</guid>
		<description>I dig your intent but I don't really like the solutions (for all obvious reasons that were already mentioned). I think the problem lies in Java itself in the lack of named arguments for methods. how about having the following more generic solution (I'm still not a big fan of it though...)

class Utils {
    $("name", name)
    public static  T $(String name, T value) {
       return value;
    }
}

then:

Customer c = new Customer($("name", "Stephan"));

I guess it's the closest you can get to: new Customer (name: "Stephan");

cheers,
Uri</description>
		<content:encoded><![CDATA[<p>I dig your intent but I don&#8217;t really like the solutions (for all obvious reasons that were already mentioned). I think the problem lies in Java itself in the lack of named arguments for methods. how about having the following more generic solution (I&#8217;m still not a big fan of it though&#8230;)</p>
<p>class Utils {<br />
    $(&#8221;name&#8221;, name)<br />
    public static  T $(String name, T value) {<br />
       return value;<br />
    }<br />
}</p>
<p>then:</p>
<p>Customer c = new Customer($(&#8221;name&#8221;, &#8220;Stephan&#8221;));</p>
<p>I guess it&#8217;s the closest you can get to: new Customer (name: &#8220;Stephan&#8221;);</p>
<p>cheers,<br />
Uri</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nick Westgate</title>
		<link>http://www.codemonkeyism.com/archives/2008/05/09/bending-java-more-readable-code-with-methods-that-do-nothing/#comment-87430</link>
		<dc:creator>Nick Westgate</dc:creator>
		<pubDate>Sun, 11 May 2008 01:26:59 +0000</pubDate>
		<guid isPermaLink="false">http://stephan.reposita.org/archives/2008/05/09/bending-java-more-readable-code-with-methods-that-do-nothing/#comment-87430</guid>
		<description>While it's always good to try new ways of improving readability, there are "better" (at least less controversial) existing solutions to the trivial example you provide - e.g. raveman's above.

Here's another traditional solution that doesn't need methods:

String name = "Stephan";
Customer customer = new Customer(name);

Some parameters might be deserving of an object type, like the OrderId in your previous post on this topic, but you should carefully consider how methods will look _when they are actually used_.

For instance, the following is common, and makes the method signature less relevant since context is provided in other ways.

Customer customer = new Customer(htmlForm.name);

Cheers,
Nick.</description>
		<content:encoded><![CDATA[<p>While it&#8217;s always good to try new ways of improving readability, there are &#8220;better&#8221; (at least less controversial) existing solutions to the trivial example you provide - e.g. raveman&#8217;s above.</p>
<p>Here&#8217;s another traditional solution that doesn&#8217;t need methods:</p>
<p>String name = &#8220;Stephan&#8221;;<br />
Customer customer = new Customer(name);</p>
<p>Some parameters might be deserving of an object type, like the OrderId in your previous post on this topic, but you should carefully consider how methods will look _when they are actually used_.</p>
<p>For instance, the following is common, and makes the method signature less relevant since context is provided in other ways.</p>
<p>Customer customer = new Customer(htmlForm.name);</p>
<p>Cheers,<br />
Nick.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Casper Bang</title>
		<link>http://www.codemonkeyism.com/archives/2008/05/09/bending-java-more-readable-code-with-methods-that-do-nothing/#comment-87425</link>
		<dc:creator>Casper Bang</dc:creator>
		<pubDate>Sun, 11 May 2008 01:03:56 +0000</pubDate>
		<guid isPermaLink="false">http://stephan.reposita.org/archives/2008/05/09/bending-java-more-readable-code-with-methods-that-do-nothing/#comment-87425</guid>
		<description>Points for originality but.... that's about it. How about we get object initializes, like in C#?

Customer customer = new Customer(){ name="Stephan", salary=65.000};

...then again, a little easier to do in C# than Java since it has native properties rather than mundane manual set/get mechanics.</description>
		<content:encoded><![CDATA[<p>Points for originality but&#8230;. that&#8217;s about it. How about we get object initializes, like in C#?</p>
<p>Customer customer = new Customer(){ name=&#8221;Stephan&#8221;, salary=65.000};</p>
<p>&#8230;then again, a little easier to do in C# than Java since it has native properties rather than mundane manual set/get mechanics.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jan</title>
		<link>http://www.codemonkeyism.com/archives/2008/05/09/bending-java-more-readable-code-with-methods-that-do-nothing/#comment-87409</link>
		<dc:creator>jan</dc:creator>
		<pubDate>Sat, 10 May 2008 22:53:30 +0000</pubDate>
		<guid isPermaLink="false">http://stephan.reposita.org/archives/2008/05/09/bending-java-more-readable-code-with-methods-that-do-nothing/#comment-87409</guid>
		<description>Having classes like Name, PhoneNumber... can really become maintainability nightmare. But I also like to increase readability of the code. My favorite would be:

Customer customer = Customer.name("Stephan").phoneNumber("12345")

or

Customer customer = Customer.withName("Stephan").withPhoneNumber("12345")</description>
		<content:encoded><![CDATA[<p>Having classes like Name, PhoneNumber&#8230; can really become maintainability nightmare. But I also like to increase readability of the code. My favorite would be:</p>
<p>Customer customer = Customer.name(&#8221;Stephan&#8221;).phoneNumber(&#8221;12345&#8243;)</p>
<p>or</p>
<p>Customer customer = Customer.withName(&#8221;Stephan&#8221;).withPhoneNumber(&#8221;12345&#8243;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: raveman</title>
		<link>http://www.codemonkeyism.com/archives/2008/05/09/bending-java-more-readable-code-with-methods-that-do-nothing/#comment-87392</link>
		<dc:creator>raveman</dc:creator>
		<pubDate>Sat, 10 May 2008 21:00:37 +0000</pubDate>
		<guid isPermaLink="false">http://stephan.reposita.org/archives/2008/05/09/bending-java-more-readable-code-with-methods-that-do-nothing/#comment-87392</guid>
		<description>i dont like that idea, how about only non-arg contructors and builder pattern ?
Customer customer = new Customer().setName("Stephan");

i think it looks better</description>
		<content:encoded><![CDATA[<p>i dont like that idea, how about only non-arg contructors and builder pattern ?<br />
Customer customer = new Customer().setName(&#8221;Stephan&#8221;);</p>
<p>i think it looks better</p>
]]></content:encoded>
	</item>
</channel>
</rss>
