<?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: Please, it is just a &#8216;var&#8217;</title>
	<atom:link href="http://elegantcode.com/2009/08/25/please-it-is-just-a-var/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com/2009/08/25/please-it-is-just-a-var/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=please-it-is-just-a-var</link>
	<description></description>
	<lastBuildDate>Tue, 07 Feb 2012 23:42:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.5</generator>
	<item>
		<title>By: WolverineOfLove</title>
		<link>http://elegantcode.com/2009/08/25/please-it-is-just-a-var/comment-page-2/#comment-49129</link>
		<dc:creator>WolverineOfLove</dc:creator>
		<pubDate>Wed, 09 Sep 2009 17:27:55 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2009/08/25/please-it-is-just-a-var/#comment-49129</guid>
		<description>&lt;a href=&quot;#comment-48955&quot; rel=&quot;nofollow&quot;&gt;@Chris Brandsma&lt;/a&gt; 
In response to use #1: Juggernaut has the right idea, and so you do in the fact that this isn&#039;t a hard and fast &quot;never use var for List.&quot; It depends entirely upon how your application is structured and how much contract-based programming is in place.

The impetus is on the developer to be aware of their usage of var and the consequences it has.

I absolutely love var for &quot;duh&quot; situations, such as how much easier it makes foreach loops and basic instantiation of variables.</description>
		<content:encoded><![CDATA[<p><a href="#comment-48955" rel="nofollow">@Chris Brandsma</a><br />
In response to use #1: Juggernaut has the right idea, and so you do in the fact that this isn&#8217;t a hard and fast &#8220;never use var for List.&#8221; It depends entirely upon how your application is structured and how much contract-based programming is in place.</p>
<p>The impetus is on the developer to be aware of their usage of var and the consequences it has.</p>
<p>I absolutely love var for &#8220;duh&#8221; situations, such as how much easier it makes foreach loops and basic instantiation of variables.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Brandsma</title>
		<link>http://elegantcode.com/2009/08/25/please-it-is-just-a-var/comment-page-2/#comment-48955</link>
		<dc:creator>Chris Brandsma</dc:creator>
		<pubDate>Mon, 31 Aug 2009 15:08:26 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2009/08/25/please-it-is-just-a-var/#comment-48955</guid>
		<description>@Juggernaut,

On 1, I can&#039;t say I agree with that.  What are you really gaining?  I don&#039;t see a whole lot.  And actually, you loose a lot of List functionality when you only use the IList.  If you are going to pass the list to another method, then the next method can be typed to the IList without any issue.

On 2, ReSharper dude, it has a built in Find by Usage that is beautiful.  It will make your life much easier.</description>
		<content:encoded><![CDATA[<p>@Juggernaut,</p>
<p>On 1, I can&#8217;t say I agree with that.  What are you really gaining?  I don&#8217;t see a whole lot.  And actually, you loose a lot of List functionality when you only use the IList.  If you are going to pass the list to another method, then the next method can be typed to the IList without any issue.</p>
<p>On 2, ReSharper dude, it has a built in Find by Usage that is beautiful.  It will make your life much easier.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Juggernaut</title>
		<link>http://elegantcode.com/2009/08/25/please-it-is-just-a-var/comment-page-2/#comment-48952</link>
		<dc:creator>Juggernaut</dc:creator>
		<pubDate>Mon, 31 Aug 2009 11:24:59 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2009/08/25/please-it-is-just-a-var/#comment-48952</guid>
		<description>2 examples of where var keyword shouldn&#039;t be used IMHO:
1)
var myList = new List(); //vs
IList myList2 = new List(); //better since we&#039;re using the Interface to access the instance.
2)
public AClass { public static SomeClass MethodFoo(); }
public BClass { public static SomeClass MethodBar(); }

var ThisAndthat = AClass.MethodFoo();

var ThisAndthat = BClass.MethodBar();

Suppose we are going to alter SomeClass and we want to start by finding references to &quot;SomeClass&quot; to find its usage. Using &quot;var&quot; will prevent us from finding those usages, unless you do &quot;Find references&quot; on both MethodFoo() and MethodBar() as well.</description>
		<content:encoded><![CDATA[<p>2 examples of where var keyword shouldn&#8217;t be used IMHO:<br />
1)<br />
var myList = new List(); //vs<br />
IList myList2 = new List(); //better since we&#8217;re using the Interface to access the instance.<br />
2)<br />
public AClass { public static SomeClass MethodFoo(); }<br />
public BClass { public static SomeClass MethodBar(); }</p>
<p>var ThisAndthat = AClass.MethodFoo();</p>
<p>var ThisAndthat = BClass.MethodBar();</p>
<p>Suppose we are going to alter SomeClass and we want to start by finding references to &#8220;SomeClass&#8221; to find its usage. Using &#8220;var&#8221; will prevent us from finding those usages, unless you do &#8220;Find references&#8221; on both MethodFoo() and MethodBar() as well.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve Py</title>
		<link>http://elegantcode.com/2009/08/25/please-it-is-just-a-var/comment-page-2/#comment-48880</link>
		<dc:creator>Steve Py</dc:creator>
		<pubDate>Thu, 27 Aug 2009 23:01:24 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2009/08/25/please-it-is-just-a-var/#comment-48880</guid>
		<description>I use var, but sparingly. In something like foreach where the scope of the instance is limited, they are invaluable. But I have seen them &quot;abused&quot; a bit in more poorly written code. 90% of the problem is the fact that the code could have been structured better, &quot;var&quot; accounted for about 10% of the headache.

What I am really starting to lose hair over is the upcoming &quot;dynamic&quot; type. Granted, it has a very good purpose behind it, but it is most definitely going to end up being something that will have been abused in many systems I&#039;m brought in to enhance/maintain in the future. If &quot;var&quot; intimidates people, &quot;dynamic&quot; will certainly cause them to fill their shorts.</description>
		<content:encoded><![CDATA[<p>I use var, but sparingly. In something like foreach where the scope of the instance is limited, they are invaluable. But I have seen them &#8220;abused&#8221; a bit in more poorly written code. 90% of the problem is the fact that the code could have been structured better, &#8220;var&#8221; accounted for about 10% of the headache.</p>
<p>What I am really starting to lose hair over is the upcoming &#8220;dynamic&#8221; type. Granted, it has a very good purpose behind it, but it is most definitely going to end up being something that will have been abused in many systems I&#8217;m brought in to enhance/maintain in the future. If &#8220;var&#8221; intimidates people, &#8220;dynamic&#8221; will certainly cause them to fill their shorts.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Brandsma</title>
		<link>http://elegantcode.com/2009/08/25/please-it-is-just-a-var/comment-page-2/#comment-48866</link>
		<dc:creator>Chris Brandsma</dc:creator>
		<pubDate>Thu, 27 Aug 2009 14:15:19 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2009/08/25/please-it-is-just-a-var/#comment-48866</guid>
		<description>@pebbles:  hungarian notation is out.  I think most developers see that way these days.

As for the ordered items/list/sorted list question...again, I don&#039;t care.  Tell me why it is important to know the difference when I access them the same way.  I need to know that when I&#039;m creating the list, and in those cases I keep that in mind.  But all of those lists can be traversed with a foreach -- so it really doesn&#039;t matter.

Basically, use the IDE (we aren&#039;t programming in notepad anymore), and take advantage of intellesence.  Work with your environment, not in spite of it.</description>
		<content:encoded><![CDATA[<p>@pebbles:  hungarian notation is out.  I think most developers see that way these days.</p>
<p>As for the ordered items/list/sorted list question&#8230;again, I don&#8217;t care.  Tell me why it is important to know the difference when I access them the same way.  I need to know that when I&#8217;m creating the list, and in those cases I keep that in mind.  But all of those lists can be traversed with a foreach &#8212; so it really doesn&#8217;t matter.</p>
<p>Basically, use the IDE (we aren&#8217;t programming in notepad anymore), and take advantage of intellesence.  Work with your environment, not in spite of it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pebbles</title>
		<link>http://elegantcode.com/2009/08/25/please-it-is-just-a-var/comment-page-2/#comment-48854</link>
		<dc:creator>pebbles</dc:creator>
		<pubDate>Thu, 27 Aug 2009 06:06:13 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2009/08/25/please-it-is-just-a-var/#comment-48854</guid>
		<description>&lt;a href=&quot;#comment-48841&quot; rel=&quot;nofollow&quot;&gt;@Jeremy Gray &lt;/a&gt; 

Are you all advocating hungarian notation? I hope not.

How do you know if it&#039;s a fixed array of order items, a list, a sorted list, ... ?

Please fix my example so that it&#039;s readable again.</description>
		<content:encoded><![CDATA[<p><a href="#comment-48841" rel="nofollow">@Jeremy Gray </a> </p>
<p>Are you all advocating hungarian notation? I hope not.</p>
<p>How do you know if it&#8217;s a fixed array of order items, a list, a sorted list, &#8230; ?</p>
<p>Please fix my example so that it&#8217;s readable again.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Williams</title>
		<link>http://elegantcode.com/2009/08/25/please-it-is-just-a-var/comment-page-1/#comment-48851</link>
		<dc:creator>David Williams</dc:creator>
		<pubDate>Wed, 26 Aug 2009 23:07:18 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2009/08/25/please-it-is-just-a-var/#comment-48851</guid>
		<description>The only issue that I have with &quot;var&quot; is that unless you are very careful occasionally it will infer the wrong type.  I have had this happen when expecting the value to to be the higher level interface (a interface that derived from IList), but it choose the lowest level (IEnumerable) instead.</description>
		<content:encoded><![CDATA[<p>The only issue that I have with &#8220;var&#8221; is that unless you are very careful occasionally it will infer the wrong type.  I have had this happen when expecting the value to to be the higher level interface (a interface that derived from IList), but it choose the lowest level (IEnumerable) instead.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Brandsma</title>
		<link>http://elegantcode.com/2009/08/25/please-it-is-just-a-var/comment-page-1/#comment-48842</link>
		<dc:creator>Chris Brandsma</dc:creator>
		<pubDate>Wed, 26 Aug 2009 15:24:21 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2009/08/25/please-it-is-just-a-var/#comment-48842</guid>
		<description>@Jeremy Gray: cool, I&#039;ll look into the foreach a bit more.  I love research after all.  Here is a good starter: http://www.csharphelp.com/archives4/archive690.html

@pebbles: the key components are the compiler and your tests.  Knowing explicitly that the variable is a particular type does not always help readability.  In fact, it often hurts readability -- especially when you start dealing with generic types, you get 30 characters of type declaration BEFORE you see any code.  And in the end, it tells you very little.

@Stubbs: substitute Pythod for JavaScriptand yes.</description>
		<content:encoded><![CDATA[<p>@Jeremy Gray: cool, I&#8217;ll look into the foreach a bit more.  I love research after all.  Here is a good starter: <a href="http://www.csharphelp.com/archives4/archive690.html" rel="nofollow">http://www.csharphelp.com/archives4/archive690.html</a></p>
<p>@pebbles: the key components are the compiler and your tests.  Knowing explicitly that the variable is a particular type does not always help readability.  In fact, it often hurts readability &#8212; especially when you start dealing with generic types, you get 30 characters of type declaration BEFORE you see any code.  And in the end, it tells you very little.</p>
<p>@Stubbs: substitute Pythod for JavaScriptand yes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeremy Gray</title>
		<link>http://elegantcode.com/2009/08/25/please-it-is-just-a-var/comment-page-1/#comment-48841</link>
		<dc:creator>Jeremy Gray</dc:creator>
		<pubDate>Wed, 26 Aug 2009 15:10:53 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2009/08/25/please-it-is-just-a-var/#comment-48841</guid>
		<description>@Chris - foreach behaviour is actually not tied to those interfaces, it is instead duck-typed by the compiler. The interfaces exist solely to help ensure that people implement the necessary members and to provide a usage hint as to the available functionality. Surprising, but true.

@pebbles - I&#039;m more of a (inferred) static typing guy myself, but it needs to be said that developers using languages that support inferred static typing or even full-on late-bound dynamic typing have been doing just fine for years and years, so the question you should be asking yourself is why are _you_ having that readability issue? Did you name the variable poorly? The method? Is the code around that line a mess that clouds the intent of code? And so on. If you _really_ need the type in place of var, I dare say the code has problems larger than its use of var. :)</description>
		<content:encoded><![CDATA[<p>@Chris &#8211; foreach behaviour is actually not tied to those interfaces, it is instead duck-typed by the compiler. The interfaces exist solely to help ensure that people implement the necessary members and to provide a usage hint as to the available functionality. Surprising, but true.</p>
<p>@pebbles &#8211; I&#8217;m more of a (inferred) static typing guy myself, but it needs to be said that developers using languages that support inferred static typing or even full-on late-bound dynamic typing have been doing just fine for years and years, so the question you should be asking yourself is why are _you_ having that readability issue? Did you name the variable poorly? The method? Is the code around that line a mess that clouds the intent of code? And so on. If you _really_ need the type in place of var, I dare say the code has problems larger than its use of var. <img src='http://elegantcode.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason</title>
		<link>http://elegantcode.com/2009/08/25/please-it-is-just-a-var/comment-page-1/#comment-48840</link>
		<dc:creator>Jason</dc:creator>
		<pubDate>Wed, 26 Aug 2009 15:09:21 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2009/08/25/please-it-is-just-a-var/#comment-48840</guid>
		<description>&lt;a href=&quot;#comment-48839&quot; rel=&quot;nofollow&quot;&gt;@pebbles&lt;/a&gt; 

If GetOrderItems doesn&#039;t return a collection of OrderItem, than there is something significantly wrong with that function name.

But if you absolutely need to know what type orderItems is, any decent IDE will tell you this very simply.

In short, if you are relying on a type declaration to tell you what type a function is returning, you should reconsider the name of your function.</description>
		<content:encoded><![CDATA[<p><a href="#comment-48839" rel="nofollow">@pebbles</a> </p>
<p>If GetOrderItems doesn&#8217;t return a collection of OrderItem, than there is something significantly wrong with that function name.</p>
<p>But if you absolutely need to know what type orderItems is, any decent IDE will tell you this very simply.</p>
<p>In short, if you are relying on a type declaration to tell you what type a function is returning, you should reconsider the name of your function.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

