title: Should I use hungarian apps notation in C#?
body: <p>I know this question has been asked around a bit, and by the looks of it, there isn't a clear yes or no answer to this question, but still, I'm a little confused about something.</p>
  
  <p>Usually when I program, I follow a few rules about prefixes:</p>
  
  <ul>
  <li>m_ in front of members</li>
  <li>p_ in front of properties</li>
  <li>s_ in front of static</li>
  <li>a_ in front of parameters</li>
  <li>l_ in front of local variables</li>
  </ul>
  
  <p>I got a new job right now, and I noticed that prefixes are not used in code. I asked why, and they replied that IDEs do all the work of keeping track of what's a member variable and what's a local variable. Now I'm thinking, that may be so, but isn't it easier to use prefixes anyway?</p>
  
  <p>I mean, if I for example have a member, a static, and a local variable named "robot", would it not be a pain in the ass to reference it when writing a method? This is perhaps an unrealistic example, but I like to have a good rule-set in my head that I can apply consistently, even for unrealistic conditions.</p>
  
  <p>Does this example justify using Hungarian notation?</p>
  
  <p>I think I'll make a pros/cons list and edit it as I learn more about it.</p>
  
  <p><strong>Argument against hungarian:</strong></p>
  
  <p><code>Class.Robot</code> or <code>Robot</code></p>
  
  <p><code>this.robot</code></p>
  
  <p><code>robot</code></p>
  
  <p>No need for Hungarian.</p>
  
  <p><strong>Counter:</strong></p>
  
  <p>There is still an inconsistency, Robot could mean different things in different methods. To stay consistent you should prefix Class or this (or nothing) before each Robot variable.</p>
  
  <p>On top of that, lets say you want to access the static variable Strawberry, how do you know a member variable named Strawberry isn't defined? Maybe it's defined in another file that you can't see, so you might get unexpected results. Now you might say that this is visible via the IDE but I make the argument that using a prefix is superior because you see what you're referencing, while you might miss what the IDE is telling you. You could also use this/Classname prefixes of course but that kind of defeats the purpose of not using a Hungarian notation.</p>
  
  <p><strong>Argument against hungarian:</strong></p>
  
  <p>A violation of this rule occurs when Hungarian notation is used in the naming of fields and variables. The use of Hungarian notation has become widespread in C++ code, but the trend in C# is to use longer, more descriptive names for variables, which are not based on the type of the variable but which instead describe what the variable is used for.</p>
  
  <p><strong>Counter:</strong></p>
  
  <p>The prefixes I mentioned are not based on the type of the variable, the prefixes indeed specify what the variable is used for.</p>
  
  <p><strong>Argument against hungarian:</strong></p>
  
  <p>modern code editors such as Visual Studio make it easy to identify type information for a variable or field, typically by hovering the mouse cursor over the variable name. This reduces the need for Hungarian notation.</p>
  
  <p><strong>Counter:</strong></p>
  
  <p>While this is true, I myself almost never hover with my mouse above a variable name unless an error has occurred. In contrast, with Hungarian notation, you immediately see where your variable is located in the class.</p>
  
  <p><strong>Remark:</strong></p>
  
  <p>Doesn't Microsoft recommend using Hungarian notation for file names? I read that it is a convention to prefix interface files with an I, this is a form of Hungarian notation. While this doesn't directly relate to my question above, it does raise the point that Hungarian notation is sometimes recommended.</p>