<?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 for Benji's Blog</title>
	<atom:link href="http://benjiweber.co.uk/blog/comments/feed/" rel="self" type="application/rss+xml" />
	<link>http://benjiweber.co.uk/blog</link>
	<description></description>
	<lastBuildDate>Fri, 27 Aug 2010 09:13:04 +0100</lastBuildDate>
	
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>Comment on Java Abuse &#8211; Ternary Try/Catch by louis vuitton</title>
		<link>http://benjiweber.co.uk/blog/2009/06/14/java-abuse-ternary-trycatch/comment-page-1/#comment-3764</link>
		<dc:creator>louis vuitton</dc:creator>
		<pubDate>Fri, 27 Aug 2010 09:13:04 +0000</pubDate>
		<guid isPermaLink="false">http://benjiweber.co.uk/blog/?p=46#comment-3764</guid>
		<description>final Customer c = new Object() {
Customer value; {
try {
value = repo.getCustomer(1);
} catch (CustomerNotFoundException e) {
value = repo.createCustomer();
}
}}.value;</description>
		<content:encoded><![CDATA[<p>final Customer c = new Object() {<br />
Customer value; {<br />
try {<br />
value = repo.getCustomer(1);<br />
} catch (CustomerNotFoundException e) {<br />
value = repo.createCustomer();<br />
}<br />
}}.value;</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Java Abuse &#8211; Ternary Try/Catch by ed hardy</title>
		<link>http://benjiweber.co.uk/blog/2009/06/14/java-abuse-ternary-trycatch/comment-page-1/#comment-3696</link>
		<dc:creator>ed hardy</dc:creator>
		<pubDate>Mon, 16 Aug 2010 02:51:48 +0000</pubDate>
		<guid isPermaLink="false">http://benjiweber.co.uk/blog/?p=46#comment-3696</guid>
		<description>Classic exposition, I have also mentioned it in my blog article. But it is a pity that almost no frienddiscussed it with me. I am very happy to see your article.</description>
		<content:encoded><![CDATA[<p>Classic exposition, I have also mentioned it in my blog article. But it is a pity that almost no frienddiscussed it with me. I am very happy to see your article.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Java Abuse &#8211; Currency Pattern by Jonathan</title>
		<link>http://benjiweber.co.uk/blog/2009/06/18/java-abuse-currency-pattern/comment-page-1/#comment-971</link>
		<dc:creator>Jonathan</dc:creator>
		<pubDate>Sat, 12 Sep 2009 11:51:50 +0000</pubDate>
		<guid isPermaLink="false">http://benjiweber.co.uk/blog/?p=72#comment-971</guid>
		<description>Ho god and here i was using this:

//The jre does not seem to provide the equivalent of std::pair
// or any other Implementation of a Tuple, the closest thing
// i could find is a internal class to Map 
// a Entry and it is a Interface...
//So without further ado basic Pair implementation,
// because i just cannot live without it
public final class Pair
{
	private F mFirst;
	private S mSecond;
	
	public Pair(final F inFirst, final S inSecond)
	{
		super();

		mFirst = inFirst;
		mSecond = inSecond;
	}

	public F first()
	{
		return mFirst;
	}

	public S second()
	{
		return mSecond;
	}

	public void setFirst(final F inFirst)
	{
		mFirst = inFirst;
	}

	public void setSecond(final S inSecond)
	{
		mSecond = inSecond;
	}
}</description>
		<content:encoded><![CDATA[<p>Ho god and here i was using this:</p>
<p>//The jre does not seem to provide the equivalent of std::pair<br />
// or any other Implementation of a Tuple, the closest thing<br />
// i could find is a internal class to Map<br />
// a Entry and it is a Interface&#8230;<br />
//So without further ado basic Pair implementation,<br />
// because i just cannot live without it<br />
public final class Pair<br />
{<br />
	private F mFirst;<br />
	private S mSecond;</p>
<p>	public Pair(final F inFirst, final S inSecond)<br />
	{<br />
		super();</p>
<p>		mFirst = inFirst;<br />
		mSecond = inSecond;<br />
	}</p>
<p>	public F first()<br />
	{<br />
		return mFirst;<br />
	}</p>
<p>	public S second()<br />
	{<br />
		return mSecond;<br />
	}</p>
<p>	public void setFirst(final F inFirst)<br />
	{<br />
		mFirst = inFirst;<br />
	}</p>
<p>	public void setSecond(final S inSecond)<br />
	{<br />
		mSecond = inSecond;<br />
	}<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Java Abuse &#8211; Ternary Try/Catch by robermann79</title>
		<link>http://benjiweber.co.uk/blog/2009/06/14/java-abuse-ternary-trycatch/comment-page-1/#comment-554</link>
		<dc:creator>robermann79</dc:creator>
		<pubDate>Mon, 15 Jun 2009 10:18:25 +0000</pubDate>
		<guid isPermaLink="false">http://benjiweber.co.uk/blog/?p=46#comment-554</guid>
		<description>Why do you have necessity to keep &quot;final&quot; that pointer? How are you going to use it?
Not knowing your real purpose, here&#039;s my way:
		String temp;
		try{
			temp = &quot;ok&quot;;
		}catch(Throwable t){
			temp = &quot;ko&quot;;
		}
		final String def = temp;
              //Then, if you wish:
             temp = null;</description>
		<content:encoded><![CDATA[<p>Why do you have necessity to keep &#8220;final&#8221; that pointer? How are you going to use it?<br />
Not knowing your real purpose, here&#8217;s my way:<br />
		String temp;<br />
		try{<br />
			temp = &#8220;ok&#8221;;<br />
		}catch(Throwable t){<br />
			temp = &#8220;ko&#8221;;<br />
		}<br />
		final String def = temp;<br />
              //Then, if you wish:<br />
             temp = null;</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Java Abuse &#8211; Ternary Try/Catch by Paczesiowa</title>
		<link>http://benjiweber.co.uk/blog/2009/06/14/java-abuse-ternary-trycatch/comment-page-1/#comment-551</link>
		<dc:creator>Paczesiowa</dc:creator>
		<pubDate>Mon, 15 Jun 2009 06:40:35 +0000</pubDate>
		<guid isPermaLink="false">http://benjiweber.co.uk/blog/?p=46#comment-551</guid>
		<description>public class Test {

	public static void main(String[] args) {
		final CustomerRepo r = new CustomerRepo();
		final Customer c = getCustomer2(r, 1337);
	}

	public static Customer getCustomer2(CustomerRepo r, int id) {
		try {
			return r.getCustomer(id);
		} catch (CustomerNotFoundException e) {
			return r.createCustomer();
		}
	}
}

you could also create that method in anonymous class like mullet wrote, but you wouldn\&#039;t have to create non-final variables.</description>
		<content:encoded><![CDATA[<p>public class Test {</p>
<p>	public static void main(String[] args) {<br />
		final CustomerRepo r = new CustomerRepo();<br />
		final Customer c = getCustomer2(r, 1337);<br />
	}</p>
<p>	public static Customer getCustomer2(CustomerRepo r, int id) {<br />
		try {<br />
			return r.getCustomer(id);<br />
		} catch (CustomerNotFoundException e) {<br />
			return r.createCustomer();<br />
		}<br />
	}<br />
}</p>
<p>you could also create that method in anonymous class like mullet wrote, but you wouldn\&#8217;t have to create non-final variables.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Java Abuse &#8211; Ternary Try/Catch by mullet</title>
		<link>http://benjiweber.co.uk/blog/2009/06/14/java-abuse-ternary-trycatch/comment-page-1/#comment-547</link>
		<dc:creator>mullet</dc:creator>
		<pubDate>Sun, 14 Jun 2009 16:21:41 +0000</pubDate>
		<guid isPermaLink="false">http://benjiweber.co.uk/blog/?p=46#comment-547</guid>
		<description>My initial thought was - why not just take the simplest route and assign to a non-final variable, then re-assign that to a final behaviour?  Of course that leaks state, and so is an unacceptable solution.  Consequently I am inclined to consider the following:

final Customer c = new Object() {
	Customer value; {
	try {
		value = repo.getCustomer(1);
	} catch (CustomerNotFoundException e) {
		value = repo.createCustomer();
	}
}}.value;

Essentially we simply hide the temporary variable \&#039;value\&#039; by wrapping it up in an object.  I\&#039;m not that its a better solution to your, but I offer it as an alternative.

Advantages:
  1. Simpler for the person who coded it to understand, since it looks more like a normal try/catch block.
  2. If the \&#039;getCustomer\&#039; method throws a RuntimeException then you will simply get it straight away, where as it gets wrapped in another RuntimeException with your solution.
  3. No requirement for reflection hacks, that have potentially negative performance impact, and would require more knowledge on behalf of the reader.
  4. Easier to Extend - chaining TryCatch instances would result in some pretty horrific nested inner class declarations, though I suppose one could build a TryCatch2, TryCatch3 etc. and abstract some of the mess a bit.  In my solution you simply add another catch block.

Disadvantages:
  1.  Your approach encourages better code reuse, since you have built a generic try/catch abstraction, rather than requiring a one-off construct.
  2. Uncertain where to place the braces.  My placement of braces above would break the code style guidelines in many projects, but reflects my intuition that \&#039;value\&#039; is really part of the method, and being wrapped in an object is simply there to hide the state.  Which is correct is really up to you.
  3. Anonymous Constructors look weird in Java.
  4. The introduction of temporary state is still a crime against humanity, even if it is cleanly abstracted.</description>
		<content:encoded><![CDATA[<p>My initial thought was &#8211; why not just take the simplest route and assign to a non-final variable, then re-assign that to a final behaviour?  Of course that leaks state, and so is an unacceptable solution.  Consequently I am inclined to consider the following:</p>
<p>final Customer c = new Object() {<br />
	Customer value; {<br />
	try {<br />
		value = repo.getCustomer(1);<br />
	} catch (CustomerNotFoundException e) {<br />
		value = repo.createCustomer();<br />
	}<br />
}}.value;</p>
<p>Essentially we simply hide the temporary variable \&#8217;value\&#8217; by wrapping it up in an object.  I\&#8217;m not that its a better solution to your, but I offer it as an alternative.</p>
<p>Advantages:<br />
  1. Simpler for the person who coded it to understand, since it looks more like a normal try/catch block.<br />
  2. If the \&#8217;getCustomer\&#8217; method throws a RuntimeException then you will simply get it straight away, where as it gets wrapped in another RuntimeException with your solution.<br />
  3. No requirement for reflection hacks, that have potentially negative performance impact, and would require more knowledge on behalf of the reader.<br />
  4. Easier to Extend &#8211; chaining TryCatch instances would result in some pretty horrific nested inner class declarations, though I suppose one could build a TryCatch2, TryCatch3 etc. and abstract some of the mess a bit.  In my solution you simply add another catch block.</p>
<p>Disadvantages:<br />
  1.  Your approach encourages better code reuse, since you have built a generic try/catch abstraction, rather than requiring a one-off construct.<br />
  2. Uncertain where to place the braces.  My placement of braces above would break the code style guidelines in many projects, but reflects my intuition that \&#8217;value\&#8217; is really part of the method, and being wrapped in an object is simply there to hide the state.  Which is correct is really up to you.<br />
  3. Anonymous Constructors look weird in Java.<br />
  4. The introduction of temporary state is still a crime against humanity, even if it is cleanly abstracted.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Software Portal Preview Available. by someone</title>
		<link>http://benjiweber.co.uk/blog/2009/02/02/software-portal-preview-available/comment-page-1/#comment-266</link>
		<dc:creator>someone</dc:creator>
		<pubDate>Thu, 05 Feb 2009 19:28:31 +0000</pubDate>
		<guid isPermaLink="false">http://benjiweber.co.uk/blog/?p=34#comment-266</guid>
		<description>in the &quot;List of applications&quot;, for example,
would be nice to have the navigation between pages e.g.

 &lt;&lt;  &gt;&gt;

also at the bottom! 

It would make a lot of sense... 

Everything else seems to be working fine!!!

It&#039;s going to be wonderful when this is up :)

Good Job</description>
		<content:encoded><![CDATA[<p>in the &#8220;List of applications&#8221;, for example,<br />
would be nice to have the navigation between pages e.g.</p>
<p> &lt;&lt;  &gt;&gt;</p>
<p>also at the bottom! </p>
<p>It would make a lot of sense&#8230; </p>
<p>Everything else seems to be working fine!!!</p>
<p>It&#8217;s going to be wonderful when this is up <img src='http://benjiweber.co.uk/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Good Job</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Software Portal Preview Available. by someone</title>
		<link>http://benjiweber.co.uk/blog/2009/02/02/software-portal-preview-available/comment-page-1/#comment-265</link>
		<dc:creator>someone</dc:creator>
		<pubDate>Thu, 05 Feb 2009 19:21:08 +0000</pubDate>
		<guid isPermaLink="false">http://benjiweber.co.uk/blog/?p=34#comment-265</guid>
		<description>in the \</description>
		<content:encoded><![CDATA[<p>in the \</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Software Portal Preview Available. by robermann79</title>
		<link>http://benjiweber.co.uk/blog/2009/02/02/software-portal-preview-available/comment-page-1/#comment-262</link>
		<dc:creator>robermann79</dc:creator>
		<pubDate>Tue, 03 Feb 2009 21:19:56 +0000</pubDate>
		<guid isPermaLink="false">http://benjiweber.co.uk/blog/?p=34#comment-262</guid>
		<description>We can propose any enhancement in the following page:
http://en.opensuse.org/Software_Portal/Enhancements

Good work, thank you :)</description>
		<content:encoded><![CDATA[<p>We can propose any enhancement in the following page:<br />
<a href="http://en.opensuse.org/Software_Portal/Enhancements" onclick="javascript:pageTracker._trackPageview('/outbound/comment/en.opensuse.org');" rel="nofollow">http://en.opensuse.org/Software_Portal/Enhancements</a></p>
<p>Good work, thank you <img src='http://benjiweber.co.uk/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Software Portal Preview Available. by anonymous</title>
		<link>http://benjiweber.co.uk/blog/2009/02/02/software-portal-preview-available/comment-page-1/#comment-261</link>
		<dc:creator>anonymous</dc:creator>
		<pubDate>Tue, 03 Feb 2009 21:08:23 +0000</pubDate>
		<guid isPermaLink="false">http://benjiweber.co.uk/blog/?p=34#comment-261</guid>
		<description>Too huge fonts on the left side.</description>
		<content:encoded><![CDATA[<p>Too huge fonts on the left side.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
