<?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: Groovy&#8217;s ?. operator in PHP. Sort of.</title>
	<atom:link href="http://justafewlines.com/2009/10/groovys-operator-in-php-sort-of/feed/" rel="self" type="application/rss+xml" />
	<link>http://justafewlines.com/2009/10/groovys-operator-in-php-sort-of/</link>
	<description>That&#039;s all it takes, usually...</description>
	<lastBuildDate>Mon, 26 Apr 2010 05:19:17 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Pawel</title>
		<link>http://justafewlines.com/2009/10/groovys-operator-in-php-sort-of/comment-page-1/#comment-17</link>
		<dc:creator>Pawel</dc:creator>
		<pubDate>Thu, 08 Oct 2009 12:31:02 +0000</pubDate>
		<guid isPermaLink="false">http://justafewlines.com/?p=174#comment-17</guid>
		<description>@Jonatan: That&#039;s a very good point. Aside from more natural flow it would be much faster too

Unfortunately, null objects have couple major drawbacks. First of all, you need to modify every method that could return null. But what&#039;s worse, you need to modify all client code. That leads to the dilemma: do we return null objects everywhere for consistency? If so, number of classes doubles by definition. There&#039;s also increasing performance penalty attached...

I guess these are some reasons why the NullObject pattern is not that popular in practice. Groovy&#039;s/Java 7 approach is nice because it&#039;s orthogonal and &quot;optional&quot;. That&#039;s what I wanted to achieve here.

@Giorgio: well, if you&#039;re listing contacts in an HTML template, you have to traverse objects hierarchy anyway, so I think this approach doesn&#039;t break anything that wasn&#039;t broken anyway :)</description>
		<content:encoded><![CDATA[<p>@Jonatan: That&#8217;s a very good point. Aside from more natural flow it would be much faster too</p>
<p>Unfortunately, null objects have couple major drawbacks. First of all, you need to modify every method that could return null. But what&#8217;s worse, you need to modify all client code. That leads to the dilemma: do we return null objects everywhere for consistency? If so, number of classes doubles by definition. There&#8217;s also increasing performance penalty attached&#8230;</p>
<p>I guess these are some reasons why the NullObject pattern is not that popular in practice. Groovy&#8217;s/Java 7 approach is nice because it&#8217;s orthogonal and &#8220;optional&#8221;. That&#8217;s what I wanted to achieve here.</p>
<p>@Giorgio: well, if you&#8217;re listing contacts in an HTML template, you have to traverse objects hierarchy anyway, so I think this approach doesn&#8217;t break anything that wasn&#8217;t broken anyway :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonatan</title>
		<link>http://justafewlines.com/2009/10/groovys-operator-in-php-sort-of/comment-page-1/#comment-16</link>
		<dc:creator>Jonatan</dc:creator>
		<pubDate>Thu, 08 Oct 2009 11:44:25 +0000</pubDate>
		<guid isPermaLink="false">http://justafewlines.com/?p=174#comment-16</guid>
		<description>How about using some sort of NullObject for the contact , instead of running multiple conditions to end up using nulls like in:
1.$joes_home_number = ($t = $contact_list) ?
2.                    ($t = $t-&gt;get_contact(&#039;Joe&#039;)) ?
3.                    ($t = $t-&gt;get_address(&#039;Home&#039;)) ?
4.                    $t-&gt;phone : null : null : null;

consider returning a NullObject for an empty contact to hold empty data values , thus even if &#039;Joe&#039; doesn&#039;t exist it would still return a chainable NullObject that holds the null values you are using.

Removes all conditions and allows a more natural flow</description>
		<content:encoded><![CDATA[<p>How about using some sort of NullObject for the contact , instead of running multiple conditions to end up using nulls like in:<br />
1.$joes_home_number = ($t = $contact_list) ?<br />
2.                    ($t = $t-&gt;get_contact(&#8216;Joe&#8217;)) ?<br />
3.                    ($t = $t-&gt;get_address(&#8216;Home&#8217;)) ?<br />
4.                    $t-&gt;phone : null : null : null;</p>
<p>consider returning a NullObject for an empty contact to hold empty data values , thus even if &#8216;Joe&#8217; doesn&#8217;t exist it would still return a chainable NullObject that holds the null values you are using.</p>
<p>Removes all conditions and allows a more natural flow</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Giorgio Sironi</title>
		<link>http://justafewlines.com/2009/10/groovys-operator-in-php-sort-of/comment-page-1/#comment-15</link>
		<dc:creator>Giorgio Sironi</dc:creator>
		<pubDate>Thu, 08 Oct 2009 10:31:39 +0000</pubDate>
		<guid isPermaLink="false">http://justafewlines.com/?p=174#comment-15</guid>
		<description>I know with Entity object is less important, but chained method calls like these are violation of the Law (Suggestion) of Demeter...</description>
		<content:encoded><![CDATA[<p>I know with Entity object is less important, but chained method calls like these are violation of the Law (Suggestion) of Demeter&#8230;</p>
]]></content:encoded>
	</item>
</channel>
</rss>
