<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Steve Wellens  - All Comments</title><link>http://weblogs.asp.net/stevewellens/default.aspx</link><description>&lt;br /&gt;This Blog is dedicated to programming in the .Net enviroment</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>re: Can the C# ‘var’ Keyword be Misused?</title><link>http://weblogs.asp.net/stevewellens/archive/2009/11/19/can-the-c-var-keyword-be-misused.aspx#7261846</link><pubDate>Fri, 20 Nov 2009 19:33:51 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7261846</guid><dc:creator>nicstrong</dc:creator><author>nicstrong</author><description>&lt;p&gt;var dataTable = GetXAsDataTable();&lt;/p&gt;
&lt;p&gt;1) Method name hints as to type.&lt;/p&gt;
&lt;p&gt;2) Is now more discoverable using intellisence.&lt;/p&gt;
&lt;p&gt;3) Variable name hints to type even if declaration is not in displayed.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7261846" width="1" height="1"&gt;</description></item><item><title>re: Can the C# ‘var’ Keyword be Misused?</title><link>http://weblogs.asp.net/stevewellens/archive/2009/11/19/can-the-c-var-keyword-be-misused.aspx#7261240</link><pubDate>Fri, 20 Nov 2009 07:17:07 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7261240</guid><dc:creator>Mattias Jakobsson</dc:creator><author>Mattias Jakobsson</author><description>&lt;p&gt;I agree with &amp;quot;paul.vencill&amp;quot; on this one. As long as you use any tool other then notepad (or similar) then why do you need to know what type you are actually using? Isn&amp;#39;t the methods the important thing? Doesn&amp;#39;t visual studio help you there?&lt;/p&gt;
&lt;p&gt;If you really need to know the datatype, then just name your variables and methods properly and it&amp;#39;s all solved.&lt;/p&gt;
&lt;p&gt;Another common misunderstanding I see a lot is the one &amp;quot;Mikael Lundin&amp;quot; describes. IPerson person = new SuperHero();. How is that better then var person = new SuperHero();? You still have a dependency on the class SuperHero, thats a fact. So that will gain you exactly zero advantages. You can still use it in any method that takes a IPerson.&lt;/p&gt;
&lt;p&gt;I use var everywhere. And it gain me a few advantages, like easier refactoring, while it has no disadvantages. &lt;/p&gt;
&lt;p&gt;My answer to the question is: No, var can not be misused. If you need to declare the type to be able to read the code, you are doing something wrong.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7261240" width="1" height="1"&gt;</description></item><item><title>var improves readability</title><link>http://weblogs.asp.net/stevewellens/archive/2009/11/19/can-the-c-var-keyword-be-misused.aspx#7261234</link><pubDate>Fri, 20 Nov 2009 07:12:22 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7261234</guid><dc:creator>Hadi Hariri</dc:creator><author>Hadi Hariri</author><description>&lt;p&gt;&amp;amp;#160; Countless times I’ve heard the argument that you should use the var keyword with caution, that&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7261234" width="1" height="1"&gt;</description></item><item><title>var improves readability</title><link>http://weblogs.asp.net/stevewellens/archive/2009/11/19/can-the-c-var-keyword-be-misused.aspx#7261232</link><pubDate>Fri, 20 Nov 2009 07:11:48 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7261232</guid><dc:creator>Hadi Hariri's Blog</dc:creator><author>Hadi Hariri's Blog</author><description>&lt;p&gt;var improves readability&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7261232" width="1" height="1"&gt;</description></item><item><title>re: Can the C# ‘var’ Keyword be Misused?</title><link>http://weblogs.asp.net/stevewellens/archive/2009/11/19/can-the-c-var-keyword-be-misused.aspx#7261147</link><pubDate>Fri, 20 Nov 2009 05:02:01 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7261147</guid><dc:creator>Mikael Lundin</dc:creator><author>Mikael Lundin</author><description>&lt;p&gt;I use the var keyword to reduce noise from my code, because most often, the variable type could be considered noise.&lt;/p&gt;
&lt;p&gt;As said above, using var should not change the readability of the code. The purpose by using a good variable name and the method name must be much clearer.&lt;/p&gt;
&lt;p&gt;Sometimes though, you don&amp;#39;t want to use var. When you want to make clear that the variable is a base type of an interface.&lt;/p&gt;
&lt;p&gt;IPerson person = new SuperHero();&lt;/p&gt;
&lt;p&gt;But I love to use it in a foreach where it is just noise to print out the type of the item.&lt;/p&gt;
&lt;p&gt;foreach (var person in persons) { .. }&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7261147" width="1" height="1"&gt;</description></item><item><title>re: Can the C# ‘var’ Keyword be Misused?</title><link>http://weblogs.asp.net/stevewellens/archive/2009/11/19/can-the-c-var-keyword-be-misused.aspx#7261013</link><pubDate>Fri, 20 Nov 2009 01:55:46 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7261013</guid><dc:creator>SGWellens</dc:creator><author>SGWellens</author><description>&lt;p&gt;&amp;gt;&amp;gt; So you&amp;#39;re saying that the use of &amp;quot;var&amp;quot; in the &lt;br /&gt;&amp;gt;&amp;gt; example harms the code clarity more than the poor &lt;br /&gt;&amp;gt;&amp;gt; function and variable names? Sorry, not buying it. &lt;br /&gt;&lt;/p&gt;
&lt;p&gt;No, I am not saying that.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m saying descriptive names improve maintainability.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7261013" width="1" height="1"&gt;</description></item><item><title>re: Can the C# ‘var’ Keyword be Misused?</title><link>http://weblogs.asp.net/stevewellens/archive/2009/11/19/can-the-c-var-keyword-be-misused.aspx#7260998</link><pubDate>Fri, 20 Nov 2009 01:34:30 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7260998</guid><dc:creator>Jared</dc:creator><author>Jared</author><description>&lt;p&gt;So you&amp;#39;re saying that the use of &amp;quot;var&amp;quot; in the example harms the code clarity more than the poor function and variable names? Sorry, not buying it.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7260998" width="1" height="1"&gt;</description></item><item><title>re: Can the C# ‘var’ Keyword be Misused?</title><link>http://weblogs.asp.net/stevewellens/archive/2009/11/19/can-the-c-var-keyword-be-misused.aspx#7260982</link><pubDate>Fri, 20 Nov 2009 01:12:40 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7260982</guid><dc:creator>Mark Nijhof</dc:creator><author>Mark Nijhof</author><description>&lt;p&gt;I would say make your variable name more descriptive, that is much more valuable. That way everywhere you use the variable you can read what it means. Also the implementation is much less important then its intent.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7260982" width="1" height="1"&gt;</description></item><item><title>re: Can the C# ‘var’ Keyword be Misused?</title><link>http://weblogs.asp.net/stevewellens/archive/2009/11/19/can-the-c-var-keyword-be-misused.aspx#7260965</link><pubDate>Fri, 20 Nov 2009 00:49:57 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7260965</guid><dc:creator>Brad</dc:creator><author>Brad</author><description>&lt;p&gt;I agree with your position on var. In fact I posted a blog, like you, about this very topic.&lt;/p&gt;
&lt;p&gt;I have some very specific rules about the usage of var.&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://www.bradcunningham.net/2009/10/random-nerd-debates-episode-2-var.html"&gt;www.bradcunningham.net/.../random-nerd-debates-episode-2-var.html&lt;/a&gt;&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7260965" width="1" height="1"&gt;</description></item><item><title>re: Can the C# ‘var’ Keyword be Misused?</title><link>http://weblogs.asp.net/stevewellens/archive/2009/11/19/can-the-c-var-keyword-be-misused.aspx#7260923</link><pubDate>Fri, 20 Nov 2009 00:05:44 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7260923</guid><dc:creator>SGWellens</dc:creator><author>SGWellens</author><description>&lt;p&gt;I'm surprised some would argue that the function name is important...the variable name is important...but the type name, why it doesn't matter at all!&lt;/p&gt;
&lt;p&gt;The more information you can convey with the code text, the more maintainable the code will be.&lt;/p&gt;
&lt;p&gt;Perhaps some are guilty of using lazy short-cuts and are trying to defend them. &amp;nbsp;Shame on you! &amp;nbsp;:)&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7260923" width="1" height="1"&gt;</description></item></channel></rss>