<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: Defensive programming is so groovy</title>
	<link>http://thediscoblog.com/2008/02/18/defensive-programming-is-so-groovy/</link>
	<description>Can you dig it man?</description>
	<pubDate>Wed, 09 Jul 2008 05:11:36 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.1</generator>
		<item>
		<title>By: The Disco Blog &#187; Blog Archive &#187; Concisely operating with ternaries</title>
		<link>http://thediscoblog.com/2008/02/18/defensive-programming-is-so-groovy/#comment-60930</link>
		<dc:creator>The Disco Blog &#187; Blog Archive &#187; Concisely operating with ternaries</dc:creator>
		<pubDate>Sat, 17 May 2008 16:24:20 +0000</pubDate>
		<guid>http://thediscoblog.com/2008/02/18/defensive-programming-is-so-groovy/#comment-60930</guid>
		<description>[...] operating with ternaries  One of my favorite features in Groovy is its hip ? operator, which facilitates Nullpointer navigation safety&#8211; while this feature isn&#8217;t available [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] operating with ternaries  One of my favorite features in Groovy is its hip ? operator, which facilitates Nullpointer navigation safety&#8211; while this feature isn&#8217;t available [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: it-bbr</title>
		<link>http://thediscoblog.com/2008/02/18/defensive-programming-is-so-groovy/#comment-57351</link>
		<dc:creator>it-bbr</dc:creator>
		<pubDate>Thu, 24 Apr 2008 09:26:01 +0000</pubDate>
		<guid>http://thediscoblog.com/2008/02/18/defensive-programming-is-so-groovy/#comment-57351</guid>
		<description>It´s so easy to be save - but is utterly unused</description>
		<content:encoded><![CDATA[<p>It´s so easy to be save - but is utterly unused</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: The Disco Blog &#187; Blog Archive &#187; Unadulterated Java is so groovy</title>
		<link>http://thediscoblog.com/2008/02/18/defensive-programming-is-so-groovy/#comment-47782</link>
		<dc:creator>The Disco Blog &#187; Blog Archive &#187; Unadulterated Java is so groovy</dc:creator>
		<pubDate>Fri, 07 Mar 2008 20:08:34 +0000</pubDate>
		<guid>http://thediscoblog.com/2008/02/18/defensive-programming-is-so-groovy/#comment-47782</guid>
		<description>[...] back to the getGenre method on the Song class, it turns out that Groovy also has a handy syntax for null pointer safety, consequently, I can simply that method even [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] back to the getGenre method on the Song class, it turns out that Groovy also has a handy syntax for null pointer safety, consequently, I can simply that method even [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason Rudolph</title>
		<link>http://thediscoblog.com/2008/02/18/defensive-programming-is-so-groovy/#comment-44840</link>
		<dc:creator>Jason Rudolph</dc:creator>
		<pubDate>Wed, 20 Feb 2008 04:19:07 +0000</pubDate>
		<guid>http://thediscoblog.com/2008/02/18/defensive-programming-is-so-groovy/#comment-44840</guid>
		<description>Guillaume, Guillaume, Guillaume - *Please* don't encourage people to write code like that.  While this operator is indeed handy at times, I'd only trust about 2% of all programmers to use it appropriately.  (To be clear, I'm not saying that Groovy shouldn't offer this method.  It absolutely should be there.  I'm simply saying that 98% of the people that employ it will do so poorly and in a manner that compensates for generally shoddy code.)

Andy - You're &lt;i&gt;right on&lt;/i&gt; about the false confidence of 100% code coverage.  (&lt;a href="http://blog.jayfields.com/2008/02/tests-reflect-code-quality.html" rel="nofollow"&gt;Jay Fields has a good post on this topic.&lt;a&gt;)  Bottom line: When it's that easy to get 100% test coverage and still have buggy code, there's simply no excuse for having anything less that 100% coverage.  In fact, one could argue that 100% coverage is for underachievers.  ;-)</description>
		<content:encoded><![CDATA[<p>Guillaume, Guillaume, Guillaume - *Please* don&#8217;t encourage people to write code like that.  While this operator is indeed handy at times, I&#8217;d only trust about 2% of all programmers to use it appropriately.  (To be clear, I&#8217;m not saying that Groovy shouldn&#8217;t offer this method.  It absolutely should be there.  I&#8217;m simply saying that 98% of the people that employ it will do so poorly and in a manner that compensates for generally shoddy code.)</p>
<p>Andy - You&#8217;re <i>right on</i> about the false confidence of 100% code coverage.  (<a href="http://blog.jayfields.com/2008/02/tests-reflect-code-quality.html" rel="nofollow">Jay Fields has a good post on this topic.</a><a>)  Bottom line: When it&#8217;s that easy to get 100% test coverage and still have buggy code, there&#8217;s simply no excuse for having anything less that 100% coverage.  In fact, one could argue that 100% coverage is for underachievers.  <img src='http://thediscoblog.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Defensive Programming in Groovy &#124; foojam.com</title>
		<link>http://thediscoblog.com/2008/02/18/defensive-programming-is-so-groovy/#comment-44831</link>
		<dc:creator>Defensive Programming in Groovy &#124; foojam.com</dc:creator>
		<pubDate>Wed, 20 Feb 2008 01:28:44 +0000</pubDate>
		<guid>http://thediscoblog.com/2008/02/18/defensive-programming-is-so-groovy/#comment-44831</guid>
		<description>[...] ? operator saves you from constantly having to check for null. Andrew Glover has a good example of Defensive Programming with Groovy over at The Disco Blog [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] ? operator saves you from constantly having to check for null. Andrew Glover has a good example of Defensive Programming with Groovy over at The Disco Blog [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Randy Hudson</title>
		<link>http://thediscoblog.com/2008/02/18/defensive-programming-is-so-groovy/#comment-44757</link>
		<dc:creator>Randy Hudson</dc:creator>
		<pubDate>Tue, 19 Feb 2008 16:29:35 +0000</pubDate>
		<guid>http://thediscoblog.com/2008/02/18/defensive-programming-is-so-groovy/#comment-44757</guid>
		<description>Adam, one way of acccomplishing what you want is to use the ?: ('elvis') operator:

genre?.toUpperCase() ?: ''

This operator (new to 1.5) returns the first expression unless it's a false (null, 0, empty, false) value, else the second expression.

Also note that "${null}" evaluates to 'null', not ''.</description>
		<content:encoded><![CDATA[<p>Adam, one way of acccomplishing what you want is to use the ?: (&#8217;elvis&#8217;) operator:</p>
<p>genre?.toUpperCase() ?: &#8221;</p>
<p>This operator (new to 1.5) returns the first expression unless it&#8217;s a false (null, 0, empty, false) value, else the second expression.</p>
<p>Also note that &#8220;${null}&#8221; evaluates to &#8216;null&#8217;, not &#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adam Kruszewski</title>
		<link>http://thediscoblog.com/2008/02/18/defensive-programming-is-so-groovy/#comment-44729</link>
		<dc:creator>Adam Kruszewski</dc:creator>
		<pubDate>Tue, 19 Feb 2008 13:32:49 +0000</pubDate>
		<guid>http://thediscoblog.com/2008/02/18/defensive-programming-is-so-groovy/#comment-44729</guid>
		<description>What I have to write if I would like to return empty (ie. "") gstring in place of null in your example?

Don't you think it should make a difference to write:
"${genre?.toUpperCase()}"
and
${genre?.toUpperCase()}

The first case, in my opinion, should return empty GString.
The second should return null.
If both cases return null then the GString decalaration is a little bit misleading.

Cheers,
 a.</description>
		<content:encoded><![CDATA[<p>What I have to write if I would like to return empty (ie. &#8220;&#8221;) gstring in place of null in your example?</p>
<p>Don&#8217;t you think it should make a difference to write:<br />
&#8220;${genre?.toUpperCase()}&#8221;<br />
and<br />
${genre?.toUpperCase()}</p>
<p>The first case, in my opinion, should return empty GString.<br />
The second should return null.<br />
If both cases return null then the GString decalaration is a little bit misleading.</p>
<p>Cheers,<br />
 a.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Disco Articles &#187; Blog Archive &#187; Defensive programming is so groovy</title>
		<link>http://thediscoblog.com/2008/02/18/defensive-programming-is-so-groovy/#comment-44639</link>
		<dc:creator>Disco Articles &#187; Blog Archive &#187; Defensive programming is so groovy</dc:creator>
		<pubDate>Mon, 18 Feb 2008 22:46:05 +0000</pubDate>
		<guid>http://thediscoblog.com/2008/02/18/defensive-programming-is-so-groovy/#comment-44639</guid>
		<description>[...] Original post by Andy [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] Original post by Andy [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andy</title>
		<link>http://thediscoblog.com/2008/02/18/defensive-programming-is-so-groovy/#comment-44599</link>
		<dc:creator>Andy</dc:creator>
		<pubDate>Mon, 18 Feb 2008 18:08:10 +0000</pubDate>
		<guid>http://thediscoblog.com/2008/02/18/defensive-programming-is-so-groovy/#comment-44599</guid>
		<description>Good call, sir-- I haven't the slightest clue why I am working with a GString in that method. Thanks for pointing that out, man, and yeah-- the deep object graph example is right on.</description>
		<content:encoded><![CDATA[<p>Good call, sir&#8211; I haven&#8217;t the slightest clue why I am working with a GString in that method. Thanks for pointing that out, man, and yeah&#8211; the deep object graph example is right on.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Guillaume Laforge</title>
		<link>http://thediscoblog.com/2008/02/18/defensive-programming-is-so-groovy/#comment-44597</link>
		<dc:creator>Guillaume Laforge</dc:creator>
		<pubDate>Mon, 18 Feb 2008 17:54:25 +0000</pubDate>
		<guid>http://thediscoblog.com/2008/02/18/defensive-programming-is-so-groovy/#comment-44597</guid>
		<description>Why even putting everything inside a GString? You just need to return genre?.toUpperCase().

This trick is also more appealing when you have to go through some deep objectgraph. So instead of nested if / else, you can just return car?.make?.name?.toUpperCase() withouth having to check whether car is null, and make is null, and name is null, etc.</description>
		<content:encoded><![CDATA[<p>Why even putting everything inside a GString? You just need to return genre?.toUpperCase().</p>
<p>This trick is also more appealing when you have to go through some deep objectgraph. So instead of nested if / else, you can just return car?.make?.name?.toUpperCase() withouth having to check whether car is null, and make is null, and name is null, etc.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
