<?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: Yet Another Java Trick</title>
	<atom:link href="http://dow.ngra.de/2008/04/05/yet-another-java-trick/feed/" rel="self" type="application/rss+xml" />
	<link>http://dow.ngra.de/2008/04/05/yet-another-java-trick/</link>
	<description>no buzzwords allowed</description>
	<lastBuildDate>Wed, 01 Feb 2012 18:42:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: dow.ngra.de &#187; Blog Archive &#187; Yet Another Java Trick, Revisited</title>
		<link>http://dow.ngra.de/2008/04/05/yet-another-java-trick/comment-page-1/#comment-740</link>
		<dc:creator>dow.ngra.de &#187; Blog Archive &#187; Yet Another Java Trick, Revisited</dc:creator>
		<pubDate>Tue, 10 Jun 2008 16:14:15 +0000</pubDate>
		<guid isPermaLink="false">http://dow.ngra.de/2008/04/05/yet-another-java-trick/#comment-740</guid>
		<description>[...] enough I rewrote by now both places in code that I did according to the Yet Another Java Trick. It&#8217;s a neat trick, which may come back to me in some other context, but it definitely [...]</description>
		<content:encoded><![CDATA[<p>[...] enough I rewrote by now both places in code that I did according to the Yet Another Java Trick. It&#8217;s a neat trick, which may come back to me in some other context, but it definitely [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jevgeni Kabanov</title>
		<link>http://dow.ngra.de/2008/04/05/yet-another-java-trick/comment-page-1/#comment-395</link>
		<dc:creator>Jevgeni Kabanov</dc:creator>
		<pubDate>Mon, 14 Apr 2008 07:12:14 +0000</pubDate>
		<guid isPermaLink="false">http://dow.ngra.de/2008/04/05/yet-another-java-trick/#comment-395</guid>
		<description>It&#039;s not a problem, you just have to have a sensible default result. If there isn&#039;t any just don&#039;t use this idiom :) In my case false was the acceptable default.</description>
		<content:encoded><![CDATA[<p>It&#8217;s not a problem, you just have to have a sensible default result. If there isn&#8217;t any just don&#8217;t use this idiom :) In my case false was the acceptable default.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tao Wang</title>
		<link>http://dow.ngra.de/2008/04/05/yet-another-java-trick/comment-page-1/#comment-391</link>
		<dc:creator>Tao Wang</dc:creator>
		<pubDate>Sun, 13 Apr 2008 18:34:32 +0000</pubDate>
		<guid isPermaLink="false">http://dow.ngra.de/2008/04/05/yet-another-java-trick/#comment-391</guid>
		<description>There is a problem when an exception threw with in the condtions like conditionA.
such exception will cause the method with no return value, but logged with result False.</description>
		<content:encoded><![CDATA[<p>There is a problem when an exception threw with in the condtions like conditionA.<br />
such exception will cause the method with no return value, but logged with result False.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Behrang</title>
		<link>http://dow.ngra.de/2008/04/05/yet-another-java-trick/comment-page-1/#comment-359</link>
		<dc:creator>Behrang</dc:creator>
		<pubDate>Tue, 08 Apr 2008 06:41:11 +0000</pubDate>
		<guid isPermaLink="false">http://dow.ngra.de/2008/04/05/yet-another-java-trick/#comment-359</guid>
		<description>@Kuhn: setter is void, it cant return value.</description>
		<content:encoded><![CDATA[<p>@Kuhn: setter is void, it cant return value.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jevgeni Kabanov</title>
		<link>http://dow.ngra.de/2008/04/05/yet-another-java-trick/comment-page-1/#comment-355</link>
		<dc:creator>Jevgeni Kabanov</dc:creator>
		<pubDate>Mon, 07 Apr 2008 21:40:33 +0000</pubDate>
		<guid isPermaLink="false">http://dow.ngra.de/2008/04/05/yet-another-java-trick/#comment-355</guid>
		<description>CyberMandrake: &quot;I’ve read somewhere&quot; is not the best argument. Try-finally in such a case should not anyhow significantly impair performance. It is in fact pretty same as just copying the finally block before every return (try-finally is implemented by doing a JSR jump before return an the RET jump when the block is finished, both are very cheap). If try-catch-finally would cost much the whole Java model would be broken, because checked exceptions mean you catch them a LOT.</description>
		<content:encoded><![CDATA[<p>CyberMandrake: &#8220;I’ve read somewhere&#8221; is not the best argument. Try-finally in such a case should not anyhow significantly impair performance. It is in fact pretty same as just copying the finally block before every return (try-finally is implemented by doing a JSR jump before return an the RET jump when the block is finished, both are very cheap). If try-catch-finally would cost much the whole Java model would be broken, because checked exceptions mean you catch them a LOT.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: CyberMandrake</title>
		<link>http://dow.ngra.de/2008/04/05/yet-another-java-trick/comment-page-1/#comment-354</link>
		<dc:creator>CyberMandrake</dc:creator>
		<pubDate>Mon, 07 Apr 2008 19:45:48 +0000</pubDate>
		<guid isPermaLink="false">http://dow.ngra.de/2008/04/05/yet-another-java-trick/#comment-354</guid>
		<description>Kuhn: Sure this looks creepy !!!
All: I&#039;ve read somewhere that using try-catch blocks may impair the performance, because of the way bytecode should be generated, or smth else. So I would take care with this trick and use only in really complicated if nests and lairs. The simple example would not be the case, as is the real example above mentioned.</description>
		<content:encoded><![CDATA[<p>Kuhn: Sure this looks creepy !!!<br />
All: I&#8217;ve read somewhere that using try-catch blocks may impair the performance, because of the way bytecode should be generated, or smth else. So I would take care with this trick and use only in really complicated if nests and lairs. The simple example would not be the case, as is the real example above mentioned.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adrian Kuhn</title>
		<link>http://dow.ngra.de/2008/04/05/yet-another-java-trick/comment-page-1/#comment-352</link>
		<dc:creator>Adrian Kuhn</dc:creator>
		<pubDate>Mon, 07 Apr 2008 14:01:17 +0000</pubDate>
		<guid isPermaLink="false">http://dow.ngra.de/2008/04/05/yet-another-java-trick/#comment-352</guid>
		<description>Cool.
Reminds me of this trick (encountered first in the sources of javac itself!)


// sets value and returns old value
public void setter(Object value) {
    try {
        return this.value;
    }
    finally {
        this.value = value;
    }
}</description>
		<content:encoded><![CDATA[<p>Cool.<br />
Reminds me of this trick (encountered first in the sources of javac itself!)</p>
<p>// sets value and returns old value<br />
public void setter(Object value) {<br />
    try {<br />
        return this.value;<br />
    }<br />
    finally {<br />
        this.value = value;<br />
    }<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jevgeni Kabanov</title>
		<link>http://dow.ngra.de/2008/04/05/yet-another-java-trick/comment-page-1/#comment-346</link>
		<dc:creator>Jevgeni Kabanov</dc:creator>
		<pubDate>Sun, 06 Apr 2008 20:02:24 +0000</pubDate>
		<guid isPermaLink="false">http://dow.ngra.de/2008/04/05/yet-another-java-trick/#comment-346</guid>
		<description>Axel: It&#039;s a matter of taste. But I think that if you are already creating extra methods then delegating the actual functionality is better than delegating the logging (that is you should rename the method() to doMethod() and create a method() that does the logging).</description>
		<content:encoded><![CDATA[<p>Axel: It&#8217;s a matter of taste. But I think that if you are already creating extra methods then delegating the actual functionality is better than delegating the logging (that is you should rename the method() to doMethod() and create a method() that does the logging).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Axel Rauschmayer</title>
		<link>http://dow.ngra.de/2008/04/05/yet-another-java-trick/comment-page-1/#comment-345</link>
		<dc:creator>Axel Rauschmayer</dc:creator>
		<pubDate>Sun, 06 Apr 2008 18:44:54 +0000</pubDate>
		<guid isPermaLink="false">http://dow.ngra.de/2008/04/05/yet-another-java-trick/#comment-345</guid>
		<description>How about the following?

public static  X log(X arg) {
    logItSomehow(arg);
    return arg;
}

Then you can write the following (which is more conventional than your code, but also smaller and almost AOP):

boolean method() {
    if (conditionA) return log(resultA);
    if (conditionB) return log(resultB);
    if (conditionC) return log(resultC);
}</description>
		<content:encoded><![CDATA[<p>How about the following?</p>
<p>public static  X log(X arg) {<br />
    logItSomehow(arg);<br />
    return arg;<br />
}</p>
<p>Then you can write the following (which is more conventional than your code, but also smaller and almost AOP):</p>
<p>boolean method() {<br />
    if (conditionA) return log(resultA);<br />
    if (conditionB) return log(resultB);<br />
    if (conditionC) return log(resultC);<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kretes</title>
		<link>http://dow.ngra.de/2008/04/05/yet-another-java-trick/comment-page-1/#comment-344</link>
		<dc:creator>kretes</dc:creator>
		<pubDate>Sun, 06 Apr 2008 16:14:12 +0000</pubDate>
		<guid isPermaLink="false">http://dow.ngra.de/2008/04/05/yet-another-java-trick/#comment-344</guid>
		<description>Well - actually -&gt; the real Aspect approach would be to seperate the logging from the rest of logic in the application. Then You wouldn&#039;t have to write any wrapper for your method nor introduce not easy readable and straight solution with try-finally. You would just have to specify in the aspect, that You have to log something , while finishign executing of this method. In my opinion - AOP is a thing that should be another step into beatufil software architecture.

Anyway - nice trick ;-)</description>
		<content:encoded><![CDATA[<p>Well &#8211; actually -&gt; the real Aspect approach would be to seperate the logging from the rest of logic in the application. Then You wouldn&#8217;t have to write any wrapper for your method nor introduce not easy readable and straight solution with try-finally. You would just have to specify in the aspect, that You have to log something , while finishign executing of this method. In my opinion &#8211; AOP is a thing that should be another step into beatufil software architecture.</p>
<p>Anyway &#8211; nice trick ;-)</p>
]]></content:encoded>
	</item>
</channel>
</rss>

