<p>Is it worth learning the convention or is it a bane to readability and maintainability?</p>

[{'answer_id': 5439, 'author': 'Lasse V. Karlsen', 'author_id': 267, 'author_profile': 'https://Stackoverflow.com/users/267', 'pm_score': 7, 'selected': True, 'text': '<p>Considering that most people that use <em>Hungarian Notation</em> is following the misunderstood version of it, I\'d say it\'s pretty pointless.</p>\n\n<p>If you want to use the original definition of it, it might make more sense, but other than that it is mostly syntactic sugar.</p>\n\n<p>If you read the <a href="http://en.wikipedia.org/wiki/Hungarian_notation" rel="noreferrer">Wikipedia article</a> on the subject, you\'ll find two conflicting notations, <em>Systems Hungarian Notation</em> and <em>Apps Hungarian Notation</em>.</p>\n\n<p>The original, good, definition is the <em>Apps Hungarian Notation</em>, but most people use the <em>Systems Hungarian Notation</em>.</p>\n\n<p>As an example of the two, consider prefixing variables with l for length, a for area and v for volume.</p>\n\n<p>With such notation, the following expression makes sense:</p>\n\n<pre><code>int vBox = aBottom * lVerticalSide;\n</code></pre>\n\n<p>but this doesn\'t:</p>\n\n<pre><code>int aBottom = lSide1;\n</code></pre>\n\n<p>If you\'re mixing the prefixes, they\'re to be considered part of the equation, and volume = area * length is fine for a box, but copying a length value into an area variable should raise some red flags.</p>\n\n<p>Unfortunately, the other notation is less useful, where people prefix the variable names with the type of the value, like this:</p>\n\n<pre><code>int iLength;\nint iVolume;\nint iArea;\n</code></pre>\n\n<p>some people use n for number, or i for integer, f for float, s for string etc.</p>\n\n<p>The original prefix was meant to be used to spot problems in equations, but has somehow devolved into making the code slightly easier to read since you don\'t have to go look for the variable declaration. With todays smart editors where you can simply hover over any variable to find the full type, and not just an abbreviation for it, this type of hungarian notation has lost a lot of its meaning.</p>\n\n<p>But, you should make up your own mind. All I can say is that I don\'t use either.</p>\n\n<hr>\n\n<p><strong>Edit</strong> Just to add a short notice, while I don\'t use <em>Hungarian Notation</em>, I do use a prefix, and it\'s the underscore. I prefix all private fields of classes with a _ and otherwise spell their names as I would a property, titlecase with the first letter uppercase.</p>\n'}, {'answer_id': 5440, 'author': 'Steve Willard', 'author_id': 402, 'author_profile': 'https://Stackoverflow.com/users/402', 'pm_score': 0, 'selected': False, 'text': "<p>I've been working for IBM for the past 6 months and I haven't seen it anywhere (thank god because I hate it.) I see either camelCase or c_style.</p>\n\n<pre><code>thisMethodIsPrettyCool()\nthis_method_is_pretty_cool()\n</code></pre>\n"}, {'answer_id': 5443, 'author': 'Ray', 'author_id': 233, 'author_profile': 'https://Stackoverflow.com/users/233', 'pm_score': 0, 'selected': False, 'text': "<p>It depends on your language and environment. As a rule I wouldn't use it, unless the development environment you're in makes it hard to find the type of the variable.</p>\n\n<p>There's also two different types of Hungarian notation. See Joel's article. I can't find it (his names don't exactly make them easy to find), anyone have a link to the one I mean?</p>\n\n<p>Edit: Wedge has the article I mean in his post.</p>\n"}, {'answer_id': 5445, 'author': 'Justin Standard', 'author_id': 92, 'author_profile': 'https://Stackoverflow.com/users/92', 'pm_score': 3, 'selected': False, 'text': '<p>It is pointless (and distracting) but is in relatively heavy use at my company, at least for types like ints, strings, booleans, and doubles.</p>\n\n<p>Things like <code>sValue</code>, <code>iCount</code>, <code>dAmount</code> or <code>fAmount</code>, and <code>bFlag</code> are everywhere.</p>\n\n<p>Once upon a time there was a good reason for this convention.  Now, it is a cancer.</p>\n'}, {'answer_id': 5451, 'author': 'Orion Edwards', 'author_id': 234, 'author_profile': 'https://Stackoverflow.com/users/234', 'pm_score': 4, 'selected': False, 'text': "<p>I think hungarian notation is an interesting footnote along the 'path' to more readable code, and if done properly, is preferable to not-doing it.</p>\n\n<p>In saying that though, I'd rather do away with it, and instead of this:</p>\n\n<pre><code>int vBox = aBottom * lVerticalSide;\n</code></pre>\n\n<p>write this:</p>\n\n<pre><code>int boxVolume = bottomArea * verticalHeight;\n</code></pre>\n\n<p>It's 2008. We don't have 80 character fixed width screens anymore! </p>\n\n<p>Also, if you're writing variable names which are much longer than that you should be looking at refactoring into objects or functions anyway.</p>\n"}, {'answer_id': 5456, 'author': 'Wedge', 'author_id': 332, 'author_profile': 'https://Stackoverflow.com/users/332', 'pm_score': 5, 'selected': False, 'text': '<p>The Hungarian Naming Convention can be useful when used correctly, unfortunately it tends to be misused more often than not.</p>\n\n<p>Read Joel Spolsky\'s article <a href="http://www.joelonsoftware.com/articles/Wrong.html" rel="noreferrer">Making Wrong Code Look Wrong</a> for appropriate perspective and justification.</p>\n\n<p>Essentially, type based Hungarian notation, where variables are prefixed with information about their type (e.g. whether an object is a string, a handle, an int, etc.) is mostly useless and generally just adds overhead with very little benefit. This, sadly, is the Hungarian notation most people are familiar with. However, the intent of Hungarian notation as envisioned is to add information on the "kind" of data the variable contains. This allows you to partition kinds of data from other kinds of data which shouldn\'t be allowed to be mixed together except, possibly, through some conversion process. For example, pixel based coordinates vs. coordinates in other units, or unsafe user input versus data from safe sources, etc.</p>\n\n<p>Look at it this way, if you find yourself spelunking through code to find out information on a variable then you probably need to adjust your naming scheme to contain that information, this is the essence of the Hungarian convention.</p>\n\n<p>Note that an alternative to Hungarian notation is to use more classes to show the intent of variable usage rather than relying on primitive types everywhere.  For example, instead of having variable prefixes for unsafe user input, you can have simple string wrapper class for unsafe user input, and a separate wrapper class for safe data. This has the advantage, in strongly typed languages, of having partitioning enforced by the compiler (even in less strongly typed languages you can usually add your own tripwire code) but adds a not insignificant amount of overhead.</p>\n'}, {'answer_id': 5557, 'author': 'Jon Limjap', 'author_id': 372, 'author_profile': 'https://Stackoverflow.com/users/372', 'pm_score': 4, 'selected': False, 'text': '<p>I still use Hungarian Notation when it comes to UI elements, where several UI elements are related to a particular object/value, e.g.,</p>\n\n<p>lblFirstName for the label object, txtFirstName for the text box. I definitely can\'t name them both "FirstName" even if <em>that</em> is the concern/responsibility of both objects.</p>\n\n<p>How do others approach naming UI elements?</p>\n'}, {'answer_id': 5721, 'author': 'Jonas Follesø', 'author_id': 1199387, 'author_profile': 'https://Stackoverflow.com/users/1199387', 'pm_score': 1, 'selected': False, 'text': "<p>I use Hungarian Naming for UI elements like buttons, textboxes and lables. The main benefit is grouping in the Visual Studio Intellisense Popup. If I want to access my lables, I simply start typing lbl.... and Visual Studio will suggest all my lables, nicley grouped together.</p>\n\n<p>However, after doing more and more Silverlight and WPF stuff, leveraging data binding, I don't even name all my controls anymore, since I don't have to reference them from code-behind (since there really isn't any codebehind anymore ;)</p>\n"}, {'answer_id': 10047, 'author': 'Theo', 'author_id': 1109, 'author_profile': 'https://Stackoverflow.com/users/1109', 'pm_score': 3, 'selected': False, 'text': '<p>Sorry to follow up with a question, but does prefixing interfaces with "I" qualify as hungarian notation? If that is the case, then yes, a lot of people are using it in the real world. If not, ignore this.</p>\n'}, {'answer_id': 10099, 'author': 'ColinYounger', 'author_id': 1223, 'author_profile': 'https://Stackoverflow.com/users/1223', 'pm_score': 1, 'selected': False, 'text': "<p>What's wrong is mixing standards. </p>\n\n<p>What's right is making sure that everyone does the same thing.</p>\n\n<pre><code>int Box = iBottom * nVerticleSide\n</code></pre>\n"}, {'answer_id': 30175, 'author': 'Will', 'author_id': 3234, 'author_profile': 'https://Stackoverflow.com/users/3234', 'pm_score': 1, 'selected': False, 'text': "<blockquote>\n  <p>The original prefix was meant to be\n  used to spot problems in equations,\n  but has somehow devolved into making\n  the code slightly easier to read since\n  you don't have to go look for the\n  variable declaration. With todays\n  smart editors where you can simply\n  hover over any variable to find the\n  full type, and not just an\n  abbreviation for it, this type of\n  hungarian notation has lost a lot of\n  its meaning.</p>\n</blockquote>\n\n<p>I'm breaking the habit a little bit but prefixing with the type can be useful in JavaScript that doesn't have strong variable typing. </p>\n"}, {'answer_id': 30236, 'author': 'Grzegorz Gierlik', 'author_id': 1483, 'author_profile': 'https://Stackoverflow.com/users/1483', 'pm_score': 0, 'selected': False, 'text': "<p>Original form (The Right Hungarian Notation :) ) where prefix means type (i.e. length, quantity) of value stored by variable is OK, but not necessary in all type of applications.</p>\n\n<p>The popular form (The Wrong Hungarian Notation) where prefix means type (String, int) is useless in most of modern programming languages. </p>\n\n<p>Especially with meaningless names like strA. I can't understand we people use meaningless names with long prefixes which gives nothing.</p>\n"}, {'answer_id': 30256, 'author': 'Konrad Rudolph', 'author_id': 1968, 'author_profile': 'https://Stackoverflow.com/users/1968', 'pm_score': 1, 'selected': False, 'text': '<p>When using a dynamically typed language, I occasionally use Apps Hungarian. For statically typed languages I don\'t. See my explanation <a href="https://stackoverflow.com/questions/26086/how-do-you-make-wrong-code-look-wrong-what-patterns-do-you-use-to-avoid-semanti#26174">in the other thread</a>.</p>\n'}, {'answer_id': 53101, 'author': 'Jay Bazuzi', 'author_id': 5314, 'author_profile': 'https://Stackoverflow.com/users/5314', 'pm_score': 2, 'selected': False, 'text': "<p>When I see Hungarian discussion, I'm glad to see people thinking hard about how to make their code clearer, and how to mistakes more visible.  That's exactly what we should all be doing!</p>\n\n<p>But don't forget that you have some powerful tools at your disposal besides naming.  </p>\n\n<p><strong>Extract Method</strong> If your methods are getting so long that your variable declarations have scrolled off the top of the screen, consider making your methods smaller.  (If you have too many methods, consider a new class.)  </p>\n\n<p><strong>Strong typing</strong> If you find that you are taking <em>zip code</em>s stored in an integer variable and assigning them to a <em>shoe size</em> integer variable, consider making a class for zip codes and a class for shoe size.  Then your bug will be caught at compile time, instead of requiring careful inspection by a human.  When I do this, I usually find a bunch of zip code- and shoe size-specific logic that I've peppered around my code, which I can then move in to my new classes.  Suddenly all my code gets clearer, simpler, and protected from certain classes of bugs.  Wow.</p>\n\n<p>To sum up: yes, think hard about how you use names in code to express your ideas clearly, but also look to the other powerful OO tools you can call on.</p>\n"}, {'answer_id': 53159, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': "<p>I use type based (Systems HN) for components (eg editFirstName, lblStatus etc) as it makes autocomplete work better.  </p>\n\n<p>I sometimes use App HN for variables where the type infomation is isufficient.  Ie fpX indicates a fixed pointed variable (int type, but can't be mixed and matched with an int), rawInput for user strings that haven't been validated etc</p>\n"}, {'answer_id': 79628, 'author': 'James Wulkan', 'author_id': 12384, 'author_profile': 'https://Stackoverflow.com/users/12384', 'pm_score': 3, 'selected': False, 'text': '<p>I see Hungarian Notation as a way to circumvent the capacity of our short term memories. According to psychologists, we can store approximately <strong><a href="http://psychclassics.yorku.ca/Miller/" rel="noreferrer">7 plus-or-minus 2 chunks</a></strong> of information. The extra information added by including a prefix helps us by providing more details about the meaning of an identifier even with no other context. In other words, we can guess what a variable is for without seeing how it is used or declared. This can be avoided by applying oo techniques such as <a href="http://en.wikipedia.org/wiki/Encapsulation_(classes_-_computers)" rel="noreferrer">encapsulation</a> and the <a href="http://en.wikipedia.org/wiki/Single_responsibility_principle" rel="noreferrer">single responsibility principle</a>.</p>\n\n<p>I\'m unaware of whether or not this has been studied empirically. I would hypothesize that the amount of effort increases dramatically when we try to understand classes with more than nine instance variables or methods with more than 9 local variables.</p>\n'}, {'answer_id': 107654, 'author': 'titanae', 'author_id': 2387, 'author_profile': 'https://Stackoverflow.com/users/2387', 'pm_score': 2, 'selected': False, 'text': "<p>Isn't scope more important than type these days, e.g.</p>\n\n<ul>\n<li>l for local</li>\n<li>a for argument</li>\n<li>m for member</li>\n<li>g for global</li>\n<li>etc</li>\n</ul>\n\n<p>With modern techniques of refactoring old code, search and replace of a symbol because you changed its type is tedious, the compiler will catch type changes, but often will not catch incorrect use of scope, sensible naming conventions help here. </p>\n"}, {'answer_id': 233586, 'author': 'AgentThirteen', 'author_id': 26199, 'author_profile': 'https://Stackoverflow.com/users/26199', 'pm_score': 2, 'selected': False, 'text': "<p>I don't use a very strict sense of hungarian notation, but I do find myself using it sparing for some common custom objects to help identify them, and also I tend to prefix gui control objects with the type of control that they are. For example, labelFirstName, textFirstName, and buttonSubmit.</p>\n"}, {'answer_id': 907212, 'author': 'Jason Williams', 'author_id': 97385, 'author_profile': 'https://Stackoverflow.com/users/97385', 'pm_score': 1, 'selected': False, 'text': '<p>Hungarian notation is pointless in type-safe languages. e.g. A common prefix you will see in old Microsoft code is "lpsz" which means "long pointer to a zero-terminated string". Since the early 1700\'s we haven\'t used segmented architectures where short and long pointers exist, the normal string representation in C++ is always zero-terminated, and the compiler is type-safe so won\'t let us apply non-string operations to the string. Therefore none of this information is of any real use to a programmer - it\'s just more typing.</p>\n\n<p>However, I use a similar idea: prefixes that clarify the <strong>usage</strong> of a variable.\nThe main ones are:</p>\n\n<ul>\n<li>m = member</li>\n<li>c = const</li>\n<li>s = static</li>\n<li>v = volatile</li>\n<li>p = pointer (and pp=pointer to pointer, etc)</li>\n<li>i = index or iterator</li>\n</ul>\n\n<p>These can be combined, so a static member variable which is a pointer would be "mspName".</p>\n\n<p>Where are these useful?</p>\n\n<ul>\n<li>Where the usage is important, it is a good idea to constantly remind the programmer that a variable is (e.g.) a volatile or a pointer</li>\n<li>Pointer dereferencing used to do my head in until I used the p prefix. Now it\'s really easy to know when you have an object (Orange) a pointer to an object (pOrange) or a pointer to a pointer to an object (ppOrange). To dereference an object, just put an asterisk in front of it for each p in its name. Case solved, no more deref bugs!</li>\n<li>In constructors I usually find that a parameter name is identical to a member variable\'s name (e.g. size). I prefer to use "mSize = size;" than "size = theSize" or "this.size = size". It is also much safer: I don\'t accidentally use "size = 1" (setting the parameter) when I meant to say "mSize = 1" (setting the member)</li>\n<li>In loops, my iterator variables are all meaningful names. Most programmers use "i" or "index" and then have to make up new meaningless names ("j", "index2") when they want an inner loop. I use a meaningful name with an i prefix (iHospital, iWard, iPatient) so I always know what an iterator is iterating.</li>\n<li>In loops, you can mix several related variables by using the same base name with different prefixes: Orange orange = pOrange[iOrange]; This also means you don\'t make array indexing errors (pApple[i] looks ok, but write it as pApple[iOrange] and the error is immediately obvious).</li>\n<li>Many programmers will use my system without knowing it: by add a lengthy suffix like "Index" or "Ptr" - there isn\'t any good reason to use a longer form than a single character IMHO, so I use "i" and "p". Less typing, more consistent, easier to read.</li>\n</ul>\n\n<p>This is a simple system which adds meaningful and useful information to code, and  eliminates the possibility of many simple but common programming mistakes.</p>\n'}, {'answer_id': 1371123, 'author': 'Joshua K', 'author_id': 139609, 'author_profile': 'https://Stackoverflow.com/users/139609', 'pm_score': 0, 'selected': False, 'text': "<p>Being a PHP programmer where it's very loosely typed, I don't make a point to use it. However I will occasionally identify something as an array or as an object depending on the size of the system and the scope of the variable.</p>\n"}]
['https://Stackoverflow.com/questions/5428', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/659/']