<?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: Bad and Good (code snippets)</title>
	<atom:link href="http://blog.cherouvim.com/bad-and-good-code-snippets/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.cherouvim.com/bad-and-good-code-snippets/</link>
	<description>software engineering for beginners</description>
	<lastBuildDate>Mon, 23 Jan 2012 06:17:54 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Rob Church</title>
		<link>http://blog.cherouvim.com/bad-and-good-code-snippets/comment-page-1/#comment-4585</link>
		<dc:creator>Rob Church</dc:creator>
		<pubDate>Thu, 30 Dec 2010 23:03:51 +0000</pubDate>
		<guid isPermaLink="false">http://blog.cherouvim.com/bad-and-good-code-snippets/#comment-4585</guid>
		<description>Syntactically correct:

public ArrayList getSomething() {}

Better:

public List getSomething() {}

Even better:

public List&lt;T&gt; getSomething() {}

(Assuming that getSomething() is able to return a type-safe generic list, and isn&#039;t in fact returning a collection of arbitrary types, in which case you&#039;ve got other problems anyway. Also assumes you can use generics, and thus implies JDK 1.5, and if you can&#039;t, my sympathies.)</description>
		<content:encoded><![CDATA[<p>Syntactically correct:</p>
<p>public ArrayList getSomething() {}</p>
<p>Better:</p>
<p>public List getSomething() {}</p>
<p>Even better:</p>
<p>public List&lt;T&gt; getSomething() {}</p>
<p>(Assuming that getSomething() is able to return a type-safe generic list, and isn&#8217;t in fact returning a collection of arbitrary types, in which case you&#8217;ve got other problems anyway. Also assumes you can use generics, and thus implies JDK 1.5, and if you can&#8217;t, my sympathies.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cherouvim</title>
		<link>http://blog.cherouvim.com/bad-and-good-code-snippets/comment-page-1/#comment-1032</link>
		<dc:creator>cherouvim</dc:creator>
		<pubDate>Tue, 10 Feb 2009 17:36:15 +0000</pubDate>
		<guid isPermaLink="false">http://blog.cherouvim.com/bad-and-good-code-snippets/#comment-1032</guid>
		<description>@shaun: Good question.
The interface List contains everything that a user of a List implementation would like to do, such as add(), remove(), indexOf() etc. The point is that it shouldn&#039;t matter what the underlying implementation of List is (ArrayList? LinkedList? Vector? etc). So the client shouldn&#039;t need to downcast anyway.</description>
		<content:encoded><![CDATA[<p>@shaun: Good question.<br />
The interface List contains everything that a user of a List implementation would like to do, such as add(), remove(), indexOf() etc. The point is that it shouldn&#8217;t matter what the underlying implementation of List is (ArrayList? LinkedList? Vector? etc). So the client shouldn&#8217;t need to downcast anyway.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shaun</title>
		<link>http://blog.cherouvim.com/bad-and-good-code-snippets/comment-page-1/#comment-1031</link>
		<dc:creator>shaun</dc:creator>
		<pubDate>Tue, 10 Feb 2009 17:02:36 +0000</pubDate>
		<guid isPermaLink="false">http://blog.cherouvim.com/bad-and-good-code-snippets/#comment-1031</guid>
		<description>A noob programmer here so forgive me if I&#039;m asking a stupid question. Regarding &quot;Method exposes implementation&quot;, shouldn&#039;t it be better to return an ArrayList instead of a List? Therefore the caller (expecting an ArrayList) does not have to cast the returned value. No?

Great site btw</description>
		<content:encoded><![CDATA[<p>A noob programmer here so forgive me if I&#8217;m asking a stupid question. Regarding &#8220;Method exposes implementation&#8221;, shouldn&#8217;t it be better to return an ArrayList instead of a List? Therefore the caller (expecting an ArrayList) does not have to cast the returned value. No?</p>
<p>Great site btw</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cherouvim</title>
		<link>http://blog.cherouvim.com/bad-and-good-code-snippets/comment-page-1/#comment-965</link>
		<dc:creator>cherouvim</dc:creator>
		<pubDate>Tue, 08 Jul 2008 13:30:35 +0000</pubDate>
		<guid isPermaLink="false">http://blog.cherouvim.com/bad-and-good-code-snippets/#comment-965</guid>
		<description>Ioanni thanks for your comment.

If it helps you then good for you.
I don&#039;t think that using the ternary operator is a matter of coolness though.</description>
		<content:encoded><![CDATA[<p>Ioanni thanks for your comment.</p>
<p>If it helps you then good for you.<br />
I don&#8217;t think that using the ternary operator is a matter of coolness though.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ioannis Mavroukakis</title>
		<link>http://blog.cherouvim.com/bad-and-good-code-snippets/comment-page-1/#comment-964</link>
		<dc:creator>Ioannis Mavroukakis</dc:creator>
		<pubDate>Tue, 08 Jul 2008 13:22:42 +0000</pubDate>
		<guid isPermaLink="false">http://blog.cherouvim.com/bad-and-good-code-snippets/#comment-964</guid>
		<description>Ah the age old chestnut of readability versus one liners..for me 

String comment = request.getParameter(&quot;post&quot;);
if (comment==null) {
  comment = &quot;n/a&quot;;
}

Is much more readable and I am willing to loose the ill perceived coolness of ternary expressions.</description>
		<content:encoded><![CDATA[<p>Ah the age old chestnut of readability versus one liners..for me </p>
<p>String comment = request.getParameter(&#8220;post&#8221;);<br />
if (comment==null) {<br />
  comment = &#8220;n/a&#8221;;<br />
}</p>
<p>Is much more readable and I am willing to loose the ill perceived coolness of ternary expressions.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dik_</title>
		<link>http://blog.cherouvim.com/bad-and-good-code-snippets/comment-page-1/#comment-955</link>
		<dc:creator>dik_</dc:creator>
		<pubDate>Thu, 21 Feb 2008 15:41:02 +0000</pubDate>
		<guid isPermaLink="false">http://blog.cherouvim.com/bad-and-good-code-snippets/#comment-955</guid>
		<description>Nice snippets :)

Regarding the &quot;Too much variable scope&quot; one, may I add that a new Something instance will be created even if foo is false, taking up unnecessarily memory. So there&#039;s another reason to move the instantiation in the if block ;)</description>
		<content:encoded><![CDATA[<p>Nice snippets :)</p>
<p>Regarding the &#8220;Too much variable scope&#8221; one, may I add that a new Something instance will be created even if foo is false, taking up unnecessarily memory. So there&#8217;s another reason to move the instantiation in the if block ;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Kostaras</title>
		<link>http://blog.cherouvim.com/bad-and-good-code-snippets/comment-page-1/#comment-945</link>
		<dc:creator>John Kostaras</dc:creator>
		<pubDate>Wed, 19 Dec 2007 15:20:25 +0000</pubDate>
		<guid isPermaLink="false">http://blog.cherouvim.com/bad-and-good-code-snippets/#comment-945</guid>
		<description>http://findbugs.sourceforge.net/</description>
		<content:encoded><![CDATA[<p><a href="http://findbugs.sourceforge.net/" rel="nofollow">http://findbugs.sourceforge.net/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: papo</title>
		<link>http://blog.cherouvim.com/bad-and-good-code-snippets/comment-page-1/#comment-908</link>
		<dc:creator>papo</dc:creator>
		<pubDate>Mon, 27 Aug 2007 10:53:48 +0000</pubDate>
		<guid isPermaLink="false">http://blog.cherouvim.com/bad-and-good-code-snippets/#comment-908</guid>
		<description>ωραίο post ...παρόλα ομολογώψ ότι  συνειδητά το 

πρώτο πρώτο  και το άλλο με το return new()- 

βασικά αποφεύγω ιδιαίτερα σε pre-mature implementation την χρήση inline calls σε  return statements! από δικη μου εμπειρία καθώς ο κώδικας εξελίσσεται τέτοια inline statements με γ@μ@νε!</description>
		<content:encoded><![CDATA[<p>ωραίο post &#8230;παρόλα ομολογώψ ότι  συνειδητά το </p>
<p>πρώτο πρώτο  και το άλλο με το return new()- </p>
<p>βασικά αποφεύγω ιδιαίτερα σε pre-mature implementation την χρήση inline calls σε  return statements! από δικη μου εμπειρία καθώς ο κώδικας εξελίσσεται τέτοια inline statements με γ@μ@νε!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Kostaras</title>
		<link>http://blog.cherouvim.com/bad-and-good-code-snippets/comment-page-1/#comment-874</link>
		<dc:creator>John Kostaras</dc:creator>
		<pubDate>Wed, 22 Aug 2007 09:01:35 +0000</pubDate>
		<guid isPermaLink="false">http://blog.cherouvim.com/bad-and-good-code-snippets/#comment-874</guid>
		<description>And don´t use try-catch to make decisions; use if:

http://www.sdnshare.com/view.jsp?id=781</description>
		<content:encoded><![CDATA[<p>And don´t use try-catch to make decisions; use if:</p>
<p><a href="http://www.sdnshare.com/view.jsp?id=781" rel="nofollow">http://www.sdnshare.com/view.jsp?id=781</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Kostaras</title>
		<link>http://blog.cherouvim.com/bad-and-good-code-snippets/comment-page-1/#comment-869</link>
		<dc:creator>John Kostaras</dc:creator>
		<pubDate>Tue, 21 Aug 2007 08:14:10 +0000</pubDate>
		<guid isPermaLink="false">http://blog.cherouvim.com/bad-and-good-code-snippets/#comment-869</guid>
		<description>Πολύ ωραία τα παραπάνω και πολύ χρήσιμα που τα μάζεψες εδώ. Επίσης χρήσιμο είναι και όταν ξέρεις ότι μια μεταβλητή η παράμετρος δεν αλλάζει να την ορίζεις final. Καλή συνέχεια...</description>
		<content:encoded><![CDATA[<p>Πολύ ωραία τα παραπάνω και πολύ χρήσιμα που τα μάζεψες εδώ. Επίσης χρήσιμο είναι και όταν ξέρεις ότι μια μεταβλητή η παράμετρος δεν αλλάζει να την ορίζεις final. Καλή συνέχεια&#8230;</p>
]]></content:encoded>
	</item>
</channel>
</rss>

