<?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>Joey Gibson&#039;s Blog &#187; dotnet</title>
	<atom:link href="http://joeygibson.com/category/tech/dotnet/feed/" rel="self" type="application/rss+xml" />
	<link>http://joeygibson.com</link>
	<description>Java, Clojure, Scala, Groovy, Ruby, Python, Lisp, Objective-C, OSX, politics, religion, Koine Greek, Tae Kwon Do, Spanish and much more!</description>
	<lastBuildDate>Wed, 08 Feb 2012 03:50:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Operator Overloading Stupidity</title>
		<link>http://joeygibson.com/2004/02/17/operator-overloading-stupidity/</link>
		<comments>http://joeygibson.com/2004/02/17/operator-overloading-stupidity/#comments</comments>
		<pubDate>Tue, 17 Feb 2004 16:36:00 +0000</pubDate>
		<dc:creator>Joey Gibson</dc:creator>
				<category><![CDATA[dotnet]]></category>
		<category><![CDATA[tech]]></category>

		<guid isPermaLink="false">http://StupidOperators</guid>
		<description><![CDATA[I&#8217;m back in .NET land after living, pretty much exclusively, for the last two years in Java-and-Ruby land and while I generally like C#, I ran across something today that is really stupid. It involves operator overloading. While I actually &#8230; <a href="http://joeygibson.com/2004/02/17/operator-overloading-stupidity/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><!-- _tech_dotnet_StupidOperators --> I&#8217;m back in <a href="http://www.microsoft.com/net/">.NET</a> land  after living, pretty much exclusively, for the last two years in <a  href="http://java.sun.com">Java</a>-and-<a  href="http://www.ruby-lang.org">Ruby</a> land and while I generally  like <a href="http://msdn.microsoft.com/vcsharp/">C#</a>, I ran across  something today that is <em>really</em> stupid. It involves operator  overloading. While I actually like operator overloading and think it  can be a powerful thing, the implementation of one facet of it in C# is just  wrong. The problem is that they force you to override certain  operators in pairs instead of defining them in terms of each other or  in terms of a single method.  In other words, if I define <tt>==</tt> to check equality  then I <em>also</em> have to define <tt>!=</tt> to check  <em>in</em>equality! Why in the world should I have to do that since  inequality is the opposite of equality and can be defined in terms of  the equality operator? The same holds true for <tt><</tt> &#038;  <tt>></tt> and <tt><=</tt> &#038; <tt>>=</tt>. What you end up  with is something like this:
<pre>  <font color="#804040"> 1</font>  <font color="#2e8b57"><b>public</b></font> <font color="#2e8b57"><b>class</b></font> Foo  <font color="#804040"> 2</font>  {  <font color="#804040"> 3</font>      <font color="#2e8b57"><b>private</b></font> <font color="#2e8b57"><b>int</b></font> val;  <font color="#804040"> 4</font>  <font color="#804040"> 5</font>      <font color="#2e8b57"><b>public</b></font> Foo(<font color="#2e8b57"><b>int</b></font> val)  <font color="#804040"> 6</font>      {  <font color="#804040"> 7</font>          <font color="#804040"><b>this</b></font>.val = val;  <font color="#804040"> 8</font>      }  <font color="#804040"> 9</font>  <font color="#804040">10</font>      <font color="#2e8b57"><b>public</b></font> <font color="#2e8b57"><b>static</b></font> <font color="#2e8b57"><b>bool</b></font> operator==(Foo lhs, Foo rhs)  <font color="#804040">11</font>      {  <font color="#804040">12</font>          <font color="#804040"><b>return</b></font> lhs.val == rhs.val;  <font color="#804040">13</font>      }  <font color="#804040">14</font>  <font color="#804040">15</font>      <font color="#2e8b57"><b>public</b></font> <font color="#2e8b57"><b>static</b></font> <font color="#2e8b57"><b>bool</b></font> operator!=(Foo lhs, Foo rhs)  <font color="#804040">16</font>      {  <font color="#804040">17</font>          <font color="#804040"><b>return</b></font> ! (lhs == rhs);  <font color="#804040">18</font>      }  <font color="#804040">19</font>  }  </pre>
<p>  where the <tt>!=</tt> operator just negates a call to  <tt>==</tt>. You would repeat this process for the other two pairs if  you wanted to provide them. (And yes, I know if you provide your own  <tt>==</tt> then you have to also provide a GetHashCode method.) There  is no reason that the developer should have to do anything more than  provide a comparison operator and then let the <em>system</em> define  the other methods in terms of that comparison...  <br/><br/>  And that's exactly what <a href="http://www.ruby-lang.org">Ruby</a>  does. If you include the module called "Comparable" in your class, and  provide a comparison method called <tt><=></tt> (called the  "spaceship method" because that's what it looks like) then you get  <tt>==, !=, <, <=, > and >=</tt> for free! That's right,  by defining <em>one</em> method you get <em>six</em> defined in terms  of it automatically. Now <em>that's</em> how it should be  done! Which results in code like this:
<pre>  <font color="#804040"> 1</font>  <font color="#a020f0">class </font><font color="#2e8b57"><b>Foo</b></font>  <font color="#804040"> 2</font>  <font color="#a020f0">    include</font> <font color="#6a5acd">Comparable</font>  <font color="#800000"># Here's where the majic starts</font>  <font color="#804040"> 3</font>  <font color="#804040"> 4</font>      attr_accessor<font color="#6a5acd"> :val</font>  <font color="#804040"> 5</font>  <font color="#804040"> 6</font>  <font color="#a020f0">    def </font><font color="#008080">initialize</font>(val)  <font color="#804040"> 7</font>          <font color="#000080">self</font>.val = val  <font color="#804040"> 8</font>      <font color="#a020f0">end</font>  <font color="#804040"> 9</font>  <font color="#804040">10</font>      <font color="#800000"># comparison method; all others defined in terms of this</font>  <font color="#804040">11</font>  <font color="#a020f0">    def </font><font color="#008080"><=>(other</font>)  <font color="#804040">12</font>          val <=> other.val  <font color="#804040">13</font>      <font color="#a020f0">end</font>  <font color="#804040">14</font>  <font color="#a020f0">end</font>  </pre>
<p>  Obviously these are both trivial classes but I think you get the  point. There is no reason why you should have to define more than one  method to get all the normal comparisons that you would expect in a  language.</p>
]]></content:encoded>
			<wfw:commentRss>http://joeygibson.com/2004/02/17/operator-overloading-stupidity/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Developing .NET Compact Framework Applications</title>
		<link>http://joeygibson.com/2003/03/19/developing-net-compact-framework-applications/</link>
		<comments>http://joeygibson.com/2003/03/19/developing-net-compact-framework-applications/#comments</comments>
		<pubDate>Wed, 19 Mar 2003 14:31:00 +0000</pubDate>
		<dc:creator>Joey Gibson</dc:creator>
				<category><![CDATA[dotnet]]></category>
		<category><![CDATA[tech]]></category>

		<guid isPermaLink="false">http://Compact</guid>
		<description><![CDATA[I got my Dell Axim X5 handheld unit last night. Very nice device. Much nicer than my old Palm V. Gorgeous 16 bit color screen. Snappy response from the OS, which is PocketPC 2002. Battery life seems good. And with &#8230; <a href="http://joeygibson.com/2003/03/19/developing-net-compact-framework-applications/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I got my <a href="http://www.dell.com/us/en/dhs/products/series_pda_snp.htm">Dell Axim X5</a> handheld unit last night. Very nice device. Much nicer than my old <a href="http://www.palm.com/support/palm5/">Palm V</a>. Gorgeous 16 bit color screen. Snappy response from the OS, which is <a href="http://www.microsoft.com/mobile/pocketpc/default.asp">PocketPC 2002</a>. Battery life seems good. And with a wifi card sitting in the Compact Flash slot, I can get on my home network easily. <br/><br/> Now, here&#8217;s what&#8217;s really cool. I installed the final beta of <a href="http://msdn.microsoft.com/vstudio/productinfo/vstudio03/default.asp">Visual Studio</a> last night. (And it <em>only</em> took 2.5 hours&#8230;) Within <strong>30 minutes</strong> I had written, tested and deployed a <a href="http://msdn.microsoft.com/vstudio/device/compactfx.asp">Compact Framework</a> application to the device. Writing with CF seems to be quite a bit easier/nicer than writing with <a href="http://java.sun.com/j2me/">J2ME</a>. I haven&#8217;t looked at J2ME in quite some time, but the last time I looked it was not a fun thing to use. Writing apps for the Compact Framework, at least in my initial testing, is an absolute <em>dream</em>.</p>
]]></content:encoded>
			<wfw:commentRss>http://joeygibson.com/2003/03/19/developing-net-compact-framework-applications/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

