<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://msmvps.com/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>Naming Conventions for C#</title><link>http://msmvps.com/blogs/paulomorgado/archive/2007/05/20/naming-conventions-for-c.aspx</link><description>I&amp;#39;m a firm supporter of coding conventions (at least of my coding conventions). Software factories [ ^ ] [ ^ ] [ ^ ] and other code generation tools have been taking care of writing the tedious (and, sometimes, ugly) code but, at some point, some</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP2 (Build: 40407.4157)</generator><item><title>re: Naming Conventions for C#</title><link>http://msmvps.com/blogs/paulomorgado/archive/2007/05/20/naming-conventions-for-c.aspx#1735952</link><pubDate>Wed, 28 Oct 2009 21:45:23 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1735952</guid><dc:creator>Paulo Morgado</dc:creator><description>&lt;p&gt;Hi David,&lt;/p&gt;
&lt;p&gt;I like the case sensitiveness of C#.&lt;/p&gt;
&lt;p&gt;And after a few stack overflow exceptions, you start wondering what&amp;#39;s going on and look for a property reading or writing itself instead of its camel cased backing field. :)&lt;/p&gt;
&lt;p&gt;I’ve grown accustomed to recognize what’s camel cased and what’s pascal cased (and mi sight is not that good). Meaningless prefixes (like _, m_, c_, s_, ?_) are noise to me. And noise bothers me.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1735952" width="1" height="1"&gt;</description></item><item><title>re: Naming Conventions for C#</title><link>http://msmvps.com/blogs/paulomorgado/archive/2007/05/20/naming-conventions-for-c.aspx#1735820</link><pubDate>Wed, 28 Oct 2009 12:57:10 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1735820</guid><dc:creator>David In So. FL</dc:creator><description>&lt;p&gt;One of the things I like about VB is the fact its case insensitive. Nothng like spending a couple hours to realize its a single case letter typo. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;I am a &amp;quot;looker&amp;quot; not a character by character &amp;quot;reader&amp;quot; so I miss caps all the time. Lots of people miss seeing individual caps. &amp;nbsp;Its the way the mind works. &amp;nbsp;If you looked into it you would see that the brain is kind enough to change what we see so it looks the way we expect it to. &amp;nbsp;There are a lot of examples of this. &amp;nbsp;This is the reason caps are problematic. &amp;nbsp;Has nothing to do with a person&amp;#39;s skill at debugging.&lt;/p&gt;
&lt;p&gt;The rest will date me. &amp;nbsp;I started with vb 1.0, well actually I started with Basic from the DOS days. &lt;/p&gt;
&lt;p&gt;I like using prefix to denote scope. &amp;nbsp;m or c for class scope (depending on your upbring or shop standards if coming from vb6). They are easier to touch type then the underscore as well. &amp;nbsp; g for global variables.&lt;/p&gt;
&lt;p&gt;In all your examples you can&amp;#39;t tell at a glance what the scope is.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1735820" width="1" height="1"&gt;</description></item><item><title>re: Naming Conventions for C#</title><link>http://msmvps.com/blogs/paulomorgado/archive/2007/05/20/naming-conventions-for-c.aspx#1653899</link><pubDate>Wed, 12 Nov 2008 16:11:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1653899</guid><dc:creator>Paulo Morgado</dc:creator><description>&lt;p&gt;I had never thought of that, Dale.&lt;/p&gt;
&lt;p&gt;But my view is: why prefix it at all?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1653899" width="1" height="1"&gt;</description></item><item><title>re: Naming Conventions for C#</title><link>http://msmvps.com/blogs/paulomorgado/archive/2007/05/20/naming-conventions-for-c.aspx#1653894</link><pubDate>Wed, 12 Nov 2008 15:38:47 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1653894</guid><dc:creator>Dale</dc:creator><description>&lt;p&gt;I think the use of the underscore should be avoided in naming for all languages, including SQL. &amp;nbsp;In VB, rather than prefixing _ or m_, why not just prefix m or if you like to prefix the type, then do that.&lt;/p&gt;
&lt;p&gt;The underscore is a little finger character on a standard keyboard. &amp;nbsp;That finger does not have the strength of any of the other fingers. &amp;nbsp;Over use of the underscore and other special characters typed by the little fingers of either hand lead to repetitive motion disorders. &amp;nbsp;There just no reason to have to type an underscore over and over and over again.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1653894" width="1" height="1"&gt;</description></item><item><title>C#/VB Conventions at Matt&amp;#8217;s Blog</title><link>http://msmvps.com/blogs/paulomorgado/archive/2007/05/20/naming-conventions-for-c.aspx#1641791</link><pubDate>Tue, 22 Jul 2008 21:19:24 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1641791</guid><dc:creator>C#/VB Conventions at Matt’s Blog</dc:creator><description>&lt;p&gt;Pingback from &amp;nbsp;C#/VB Conventions at Matt&amp;#8217;s Blog&lt;/p&gt;
&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1641791" width="1" height="1"&gt;</description></item><item><title>re: Naming Conventions for C#</title><link>http://msmvps.com/blogs/paulomorgado/archive/2007/05/20/naming-conventions-for-c.aspx#1398548</link><pubDate>Sat, 15 Dec 2007 11:53:31 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1398548</guid><dc:creator>Paulo Morgado</dc:creator><description>&lt;p&gt;Wich is as good a convention as:&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;private int var;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;public int Var { ... }&lt;/font&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1398548" width="1" height="1"&gt;</description></item><item><title>re: Naming Conventions for C#</title><link>http://msmvps.com/blogs/paulomorgado/archive/2007/05/20/naming-conventions-for-c.aspx#1397796</link><pubDate>Sat, 15 Dec 2007 01:47:27 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1397796</guid><dc:creator>Craig</dc:creator><description>&lt;p&gt;I use the underscore as well, to me it means private withing the scope of the class, so:&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;private int _Var;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font face="courier new,courier"&gt;public int Var&lt;br /&gt;&lt;/font&gt;&lt;font face="courier new,courier"&gt;{&lt;/font&gt;&lt;br /&gt;&amp;nbsp; &lt;font face="courier new,courier"&gt;get { return _Var;}&lt;br /&gt;&lt;/font&gt;&lt;font face="courier new,courier"&gt;&amp;nbsp;set { _Var = value;}&lt;br /&gt;&lt;/font&gt;&lt;font face="courier new,courier"&gt;}&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;and&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;private void _PrivateMethod()&lt;br /&gt;{&lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;and &lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;public void PublicMethod()&lt;br /&gt;{&lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1397796" width="1" height="1"&gt;</description></item><item><title>re: Naming Conventions for C#</title><link>http://msmvps.com/blogs/paulomorgado/archive/2007/05/20/naming-conventions-for-c.aspx#1347728</link><pubDate>Thu, 22 Nov 2007 21:50:52 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1347728</guid><dc:creator>Paulo Morgado</dc:creator><description>&lt;p&gt;I like when things mean something to me. And, since the underscore means nothing to me, it kind of gets in my nerves.&lt;/p&gt;
&lt;p&gt;It's just the way I am.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1347728" width="1" height="1"&gt;</description></item><item><title>re: Naming Conventions for C#</title><link>http://msmvps.com/blogs/paulomorgado/archive/2007/05/20/naming-conventions-for-c.aspx#1347620</link><pubDate>Thu, 22 Nov 2007 18:41:58 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1347620</guid><dc:creator>Betty</dc:creator><description>&lt;p&gt;does it need to mean something? I would have thought the whole stopping name clashes was enough to warrant the use of another naming convention in that case. The underscore just happens to be what I use.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1347620" width="1" height="1"&gt;</description></item><item><title>re: Naming Conventions for C#</title><link>http://msmvps.com/blogs/paulomorgado/archive/2007/05/20/naming-conventions-for-c.aspx#1347298</link><pubDate>Thu, 22 Nov 2007 13:38:04 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1347298</guid><dc:creator>Paulo Morgado</dc:creator><description>&lt;p&gt;And what does the underscore prefix mean?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1347298" width="1" height="1"&gt;</description></item><item><title>re: Naming Conventions for C#</title><link>http://msmvps.com/blogs/paulomorgado/archive/2007/05/20/naming-conventions-for-c.aspx#1346614</link><pubDate>Thu, 22 Nov 2007 06:29:39 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1346614</guid><dc:creator>Betty</dc:creator><description>&lt;p&gt;So the following parameter for the function FindPerson hides the class member variable? that just seems silly. I like underscore prefixes.&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;public class Person {&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &lt;font face="courier new,courier"&gt;private int personId;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &lt;font face="courier new,courier"&gt;public int PersonId {&lt;/font&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font face="courier new,courier"&gt;get { return personId; }&lt;/font&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font face="courier new,courier"&gt;set { personId = value; }&lt;/font&gt;&lt;br /&gt;&lt;font face="courier new,courier"&gt;&lt;font face="Arial"&gt;&amp;nbsp; &lt;/font&gt;}&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font face="courier new,courier"&gt;&amp;nbsp; public void FindPerson(int personId) {&lt;/font&gt;&lt;br /&gt;&lt;font face="courier new,courier"&gt;&amp;nbsp; }&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;}&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1346614" width="1" height="1"&gt;</description></item><item><title>Naming Conventions for C#</title><link>http://msmvps.com/blogs/paulomorgado/archive/2007/05/20/naming-conventions-for-c.aspx#1346451</link><pubDate>Thu, 22 Nov 2007 04:57:03 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1346451</guid><dc:creator>DotNetKicks.com</dc:creator><description>&lt;p&gt;You've been kicked (a good thing) - Trackback from DotNetKicks.com&lt;/p&gt;
&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1346451" width="1" height="1"&gt;</description></item><item><title>re: Naming Conventions for C#</title><link>http://msmvps.com/blogs/paulomorgado/archive/2007/05/20/naming-conventions-for-c.aspx#1222345</link><pubDate>Sat, 29 Sep 2007 20:47:29 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1222345</guid><dc:creator>Paulo Morgado</dc:creator><description>&lt;p&gt;It's not without problems and It has happened to me a few times. Fortunately, this has been the only situation where I've got a StackOveflowException and I always know what and where to look.&lt;/p&gt;
&lt;p&gt;But, on the other hand, that revels that that developer was unable to debug and he can do a lot worse and not so obvious mistakes. And no amount of prefixes can help you there.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1222345" width="1" height="1"&gt;</description></item><item><title>re: Naming Conventions for C#</title><link>http://msmvps.com/blogs/paulomorgado/archive/2007/05/20/naming-conventions-for-c.aspx#1222323</link><pubDate>Sat, 29 Sep 2007 19:55:12 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1222323</guid><dc:creator>Fluxtah</dc:creator><description>&lt;p&gt;&lt;font face="courier new,courier"&gt;private int foo;&lt;br /&gt;&lt;/font&gt;&lt;font face="courier new,courier"&gt;public int Foo&lt;br /&gt;&lt;/font&gt;&lt;font face="courier new,courier"&gt;{&lt;br /&gt;&lt;/font&gt;&lt;font face="courier new,courier"&gt;&amp;nbsp; get { return foo; }&lt;br /&gt;&lt;/font&gt;&lt;font face="courier new,courier"&gt;&amp;nbsp; set { Foo = value; }&lt;br /&gt;&lt;/font&gt;&lt;font face="courier new,courier"&gt;}&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;Check the code carefully, I&amp;#39;ve seen this happen and a dev take half a day for me to come over and say &amp;#39;I see your problem, thats where your stack overflow problem is&amp;#39;&lt;/p&gt;
&lt;p&gt;And he was astonished at my good eyes.&lt;/p&gt;
&lt;p&gt;Granted, this is a head slapping mistake, maybe not enough coffee, but from my point of view having a more user friendly convention can avoid this issue, thats why I like using underscores.&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;private int _Foo&lt;/font&gt;; is much less prone to this;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1222323" width="1" height="1"&gt;</description></item><item><title>re: Naming Conventions for C#</title><link>http://msmvps.com/blogs/paulomorgado/archive/2007/05/20/naming-conventions-for-c.aspx#1049242</link><pubDate>Mon, 23 Jul 2007 22:14:42 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1049242</guid><dc:creator>Kenneth Siewers</dc:creator><description>&lt;p&gt;Well, I actually prefer using the underscore for prefixing my private fields. This is simply because they group together in Intellisense. Whenever I am looking for a private field, I just type in the underscore, and all my private fields show up (including the nasty &amp;quot;_AppDomain&amp;quot; interface Microsoft left behind).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1049242" width="1" height="1"&gt;</description></item><item><title>re: Naming Conventions for C#</title><link>http://msmvps.com/blogs/paulomorgado/archive/2007/05/20/naming-conventions-for-c.aspx#932999</link><pubDate>Wed, 30 May 2007 00:52:56 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:932999</guid><dc:creator>Paulo Morgado</dc:creator><description>&lt;p&gt;Miguel:&lt;/p&gt;
&lt;p&gt;I can differentiate them by the casing.&lt;/p&gt;
&lt;p&gt;These are &amp;quot;my&amp;quot; naming conventions for C#.&lt;/p&gt;
&lt;p&gt;I do have a proposal for case insensitive languages: suffix fields with Field.&lt;/p&gt;
&lt;p&gt;Since this convention is for private members only, there's no problem with consuming this classes using case insensitive languages.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=932999" width="1" height="1"&gt;</description></item><item><title>re: Naming Conventions for C#</title><link>http://msmvps.com/blogs/paulomorgado/archive/2007/05/20/naming-conventions-for-c.aspx#932960</link><pubDate>Tue, 29 May 2007 23:57:47 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:932960</guid><dc:creator>Miguel</dc:creator><description>&lt;p&gt;Paulo:&lt;/p&gt;
&lt;p&gt;Without the prefix how can you make a difference between a property and private member:&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;public class TestMeClass&lt;br /&gt;{&lt;br /&gt;&amp;nbsp; private int test;&lt;br /&gt;&amp;nbsp; public int Test&lt;br /&gt;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; get { return test; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set { test = value; }&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;The main issue is not for C# but for case insensitive languages such as VB.NET or Delphi.NET ( In this case these languages can interpret the variable either way; also if you are making a class library that library can be used by any .NET client).&lt;/p&gt;
&lt;p&gt;I agree with you idea of prefix, it does make the code stands out.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=932960" width="1" height="1"&gt;</description></item><item><title>My C# Naming Conventions For Partial Class Files</title><link>http://msmvps.com/blogs/paulomorgado/archive/2007/05/20/naming-conventions-for-c.aspx#922203</link><pubDate>Wed, 23 May 2007 23:29:34 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:922203</guid><dc:creator>Paulo Morgado</dc:creator><description>Following up on a previous post , this time I&amp;#39;ll give you my naming conventions for partial class&lt;img src="http://msmvps.com/aggbug.aspx?PostID=922203" width="1" height="1"&gt;</description></item><item><title>re: Naming Conventions for C#</title><link>http://msmvps.com/blogs/paulomorgado/archive/2007/05/20/naming-conventions-for-c.aspx#919912</link><pubDate>Tue, 22 May 2007 22:53:53 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:919912</guid><dc:creator>Paulo Morgado</dc:creator><description>&lt;p&gt;Well, I don't.&lt;/p&gt;
&lt;p&gt;But I can see you do.&lt;/p&gt;
&lt;p&gt;Just looking at the way we write our names everyone can see the importance each one of us gives to casing.&lt;/p&gt;
&lt;p&gt;From Jeff's referenced article (&lt;a rel="nofollow" target="_new" href="http://www.somethinkodd.com/oddthinking/2005/10/27/the-case-for-case-preserving-case-insensitivity/"&gt;www.somethinkodd.com/.../the-case-for-case-preserving-case-insensitivity&lt;/a&gt;) I only have to say that my name is Paulo Morgado and, unless it's a misstype, I wouldn't like to see it written as pAuLo MoRgAdO or some other variation.&lt;/p&gt;
&lt;p&gt;Casing is important and you agree it is. That's why you use pascal and camel casing in your code instead of underscores separating words, right?&lt;/p&gt;
&lt;p&gt;And why does the Visual Basic IDE keep correcting the casing if it's case insensitive? Why not uper case or lower case everything?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=919912" width="1" height="1"&gt;</description></item><item><title>re: Naming Conventions for C#</title><link>http://msmvps.com/blogs/paulomorgado/archive/2007/05/20/naming-conventions-for-c.aspx#919852</link><pubDate>Tue, 22 May 2007 21:44:16 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:919852</guid><dc:creator>luisabreu</dc:creator><description>&lt;p&gt;Well, i'm not sure if case sensitivity is a good thing. Jeff &amp;quot;horror&amp;quot; Atwood doesn't really like it and i think i agree with what he says here:&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://www.codinghorror.com/blog/archives/000860.html"&gt;www.codinghorror.com/.../000860.html&lt;/a&gt;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=919852" width="1" height="1"&gt;</description></item></channel></rss>