<?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"
	>
<channel>
	<title>Comments on: Stupid Reference Tricks, Part 2</title>
	<atom:link href="http://www.donniepinkston.net/2007-01-19/stupid-reference-tricks-part-2.html/feed" rel="self" type="application/rss+xml" />
	<link>http://www.donniepinkston.net/2007-01-19/stupid-reference-tricks-part-2.html</link>
	<description>(there are many more like it, but this one is mine)</description>
	<pubDate>Tue, 06 Jan 2009 09:39:14 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: donnie</title>
		<link>http://www.donniepinkston.net/2007-01-19/stupid-reference-tricks-part-2.html#comment-2512</link>
		<dc:creator>donnie</dc:creator>
		<pubDate>Thu, 25 Jan 2007 18:00:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.donniepinkston.net/2007-01-19/stupid-reference-tricks-part-2.html#comment-2512</guid>
		<description>As you say, "no one who's anyone" says that this is a good pattern.  It's clearly an anti-pattern.  Nonetheless, I have come across people using it on large-scale C++ coding projects &lt;em&gt;twice&lt;/em&gt; already here at Caltech, and I've only been here half as long as you were.

There are standard C++ APIs that do this kind of thing, too.  For example, if you look at the &lt;code&gt;std::string&lt;/code&gt; &lt;code&gt;at()&lt;/code&gt; function, it can also be used as the target of assignment.  I think that what may happen is that people see this, and they think it's a good approach in general.  They don't realize that providing a non-const reference to an internal data member is to be used &lt;em&gt;very&lt;/em&gt; infrequently, and only in very particular situations.

Anyway, by virtue of the simple fact that people are using it, somebody somewhere clearly thinks it's a good idea.  They just don't realize that it completely violates encapsulation.  If they did, hopefully they would stop using it.

All I can do is push back the boundaries of ignorance one class at a time...  ;-)</description>
		<content:encoded><![CDATA[<p>As you say, &#8220;no one who&#8217;s anyone&#8221; says that this is a good pattern.  It&#8217;s clearly an anti-pattern.  Nonetheless, I have come across people using it on large-scale C++ coding projects <em>twice</em> already here at Caltech, and I&#8217;ve only been here half as long as you were.</p>
<p>There are standard C++ APIs that do this kind of thing, too.  For example, if you look at the <code>std::string</code> <code>at()</code> function, it can also be used as the target of assignment.  I think that what may happen is that people see this, and they think it&#8217;s a good approach in general.  They don&#8217;t realize that providing a non-const reference to an internal data member is to be used <em>very</em> infrequently, and only in very particular situations.</p>
<p>Anyway, by virtue of the simple fact that people are using it, somebody somewhere clearly thinks it&#8217;s a good idea.  They just don&#8217;t realize that it completely violates encapsulation.  If they did, hopefully they would stop using it.</p>
<p>All I can do is push back the boundaries of ignorance one class at a time&#8230;  <img src='http://www.donniepinkston.net/wordpress/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben</title>
		<link>http://www.donniepinkston.net/2007-01-19/stupid-reference-tricks-part-2.html#comment-2511</link>
		<dc:creator>Ben</dc:creator>
		<pubDate>Thu, 25 Jan 2007 07:05:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.donniepinkston.net/2007-01-19/stupid-reference-tricks-part-2.html#comment-2511</guid>
		<description>Where do people say this is a good pattern?

I'm confused about the whole example.  This doesn't look like modern C++ code that anyone would be writing these days...  well, at least, anyone who's anyone.  :)</description>
		<content:encoded><![CDATA[<p>Where do people say this is a good pattern?</p>
<p>I&#8217;m confused about the whole example.  This doesn&#8217;t look like modern C++ code that anyone would be writing these days&#8230;  well, at least, anyone who&#8217;s anyone.  <img src='http://www.donniepinkston.net/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
</channel>
</rss>
