<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>stacyprowell.com &#187; reference</title>
	<atom:link href="http://stacyprowell.com/blog/tag/reference/feed/" rel="self" type="application/rss+xml" />
	<link>http://stacyprowell.com/blog</link>
	<description>Ugh, Stacy's talking again...</description>
	<lastBuildDate>Tue, 27 Apr 2010 20:09:26 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>And Another Thing That Bugs Me About Java&#8230;</title>
		<link>http://stacyprowell.com/blog/2009/09/30/and-another-thing-that-bugs-me-about-java/</link>
		<comments>http://stacyprowell.com/blog/2009/09/30/and-another-thing-that-bugs-me-about-java/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 03:05:15 +0000</pubDate>
		<dc:creator>stacy</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Nuisances]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[const]]></category>
		<category><![CDATA[immutable]]></category>
		<category><![CDATA[linkedin]]></category>
		<category><![CDATA[reference]]></category>

		<guid isPermaLink="false">http://stacyprowell.com/blog/?p=415</guid>
		<description><![CDATA[Just a short note on an item that bugs me about Java.  In C++, I tend to use exactly three kinds of method parameters.

A const reference.  I don&#8217;t want to copy it, but I promise not to modify it, either.
A reference.  I might modify it.
A copy.  I might modify my local copy, but not the [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-thumbnail wp-image-116" title="java_logo_2" src="http://stacyprowell.com/blog/wp-content/uploads/2008/07/java_logo_2-150x150.png" alt="java_logo_2" width="120" height="120" />Just a short note on an item that bugs me about Java.  In C++, I tend to use exactly three kinds of method parameters.</p>
<ul>
<li>A const reference.  I don&#8217;t want to copy it, but I promise not to modify it, either.</li>
<li>A reference.  I might modify it.</li>
<li>A copy.  I might modify my local copy, but not the original.  I&#8217;m getting a copy, after all.</li>
</ul>
<p>Easy peasy in C++.  In Java?  Uh, I pass all objects by reference.<span id="more-415"></span> The interface says nothing about modification.  Pass me a Map and maybe I&#8217;ll modify it, maybe not.  You don&#8217;t know, and you can&#8217;t enforce it.  Unless you pass me a Collections.unmodifiableMap().  Then my code might break!  There might be some odd little case left over where I do modify it, in spite of documentation comments to the contrary.  C++?  I declare it to be a const reference, and now the compiler will prevent me from modifying it.  I like that quite a bit.</p>
<p>I also like const methods, and you really can&#8217;t have const without const methods.  The Java way it to throw exceptions.  I&#8217;d rather have the compiler tell me something at compile-time than have the runtime system fail at runtime.  But I&#8217;m weird, I suppose.</p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fstacyprowell.com%2Fblog%2F2009%2F09%2F30%2Fand-another-thing-that-bugs-me-about-java%2F&amp;linkname=And%20Another%20Thing%20That%20Bugs%20Me%20About%20Java%26%238230%3B"><img src="http://stacyprowell.com/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://stacyprowell.com/blog/2009/09/30/and-another-thing-that-bugs-me-about-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
