Questions tagged [hungarian-notation]

Hungarian notation is a language-independent naming convention in which an identifier's prefix indicates its type. Examples include iCustomerId, sFirstName, etc.

Hungarian Notation is a language-independent naming convention in which an identifier's prefix contains meta information about the identifier. It could be used for type, to denote usage and/or for readability or maintainability.

Wikipedia Article

Joel Spolsky's Article

Examples

59 questions
208
votes
10 answers

What does `m_` variable prefix mean?

I often see m_ prefix used for variables (m_World,m_Sprites,...) in tutorials, examples and other code mainly related to game development. Why do people add prefix m_ to variables?
kravemir
  • 10,636
  • 17
  • 64
  • 111
122
votes
37 answers

Why shouldn't I use "Hungarian Notation"?

I know what Hungarian refers to - giving information about a variable, parameter, or type as a prefix to its name. Everyone seems to be rabidly against it, even though in some cases it seems to be a good idea. If I feel that useful information is…
Dustman
  • 5,035
  • 10
  • 32
  • 40
52
votes
9 answers

Where does the k prefix for constants come from?

it's a pretty common practice that constants are prefixed with k (e.g. k_pi). But what does the k mean? Is it simply that c already meant char?
Johan Kotlinski
  • 25,185
  • 9
  • 78
  • 101
49
votes
2 answers

What does the 'k' prefix indicate in Apple's APIs?

I've run across many examples of Core Foundation variables named k + someVariableNameHere or k + APILibraryName(2Char) + someVariableNameHere. What does this prefix K indicate? Examples include: kGLPFAStereo kCollectionLockBit kSetDebugOption
locriani
  • 4,995
  • 2
  • 23
  • 26
49
votes
25 answers

Why shouldn't I prefix my fields?

I've never been a fan of Hungarian notation, I've always found it pretty useless unless you're doing some really low level programming, but in every C++ project I've worked on some kind of Hungarian notation policy was enforced, and with it the use…
Trap
  • 12,050
  • 15
  • 55
  • 67
39
votes
29 answers

Are variable prefixes (“Hungarian notation”) really necessary anymore?

Since C# is strongly typed, do we really need to prefix variables anymore? e.g. iUserAge iCounter strUsername I used to prefix in the past, but going forward I don't see any benefit.
Blankman
  • 259,732
  • 324
  • 769
  • 1,199
34
votes
20 answers

Do people use the Hungarian Naming Conventions in the real world?

Is it worth learning the convention or is it a bane to readability and maintainability?
Brock D
  • 551
  • 1
  • 7
  • 10
16
votes
22 answers

Good Examples of Hungarian Notation?

This question is to seek out good examples of Hungarian Notation, so we can bring together a collection of these. Edit: I agree that Hungarian for types isn't that necessary, I'm hoping for more specific examples where it increases readability and…
Lance Roberts
  • 22,383
  • 32
  • 112
  • 130
13
votes
16 answers

textBoxEmployeeName vs employeeNameTextBox

Which naming convention do you use and why? I like to use employeeNameTextBox, because: It seems more natural from an English language perspective. I find it's easier to look up with Intellisense. The convention is similar to the convention used…
Dylan
  • 2,392
  • 6
  • 26
  • 34
13
votes
12 answers

Class names that start with C

The MFC has all class names that start with C. For example, CFile and CGdiObject. Has anyone seen it used elsewhere? Is there an official naming convention guide from Microsoft that recommends this style? Did the idea originate with MFC or was…
User1
  • 39,458
  • 69
  • 187
  • 265
13
votes
5 answers

Is hungarian notation applicable to Perl?

In Perl, reference to anything is a simple scalar, and has the $ sigil. It's sometimes hard to say what kind of reference it is. I personally prefix variable names for references with a letter, which indicates ref type. Examples: my $aValues =…
Eugene Yarmash
  • 142,882
  • 41
  • 325
  • 378
11
votes
2 answers

The opposite of Hungarian Notation?

Most programmers know of a thing called 'Hungarian Notation', each variable has a nice prefix to denote its data type, i.e. bIsExciting = false; // Boolean strName = "Gonzo"; // String iNumber = 10; // Integer While this style of…
A.R.
  • 15,405
  • 19
  • 77
  • 123
11
votes
2 answers

How do I prevent StyleCop warning of a Hungarian notation when prefix is valid

I have the following code: var fxRate = new FxRate(); which is giving me the following StyleCop ReSharper warning: The variable name 'fxRate' begins with a prefix that looks like Hungarian notation. I have tried copying the Settings.StyleCop…
openshac
  • 4,966
  • 5
  • 46
  • 77
10
votes
4 answers

How to fix violation of StyleCop SA1305 (Hungarian)

My code contains a variable named "m_d3dDevice". StyleCop complains about this name: SA1305: The variable name 'm_d3dDevice' begins with a prefix that looks like Hungarian notation. Remove the prefix or add it to the list of allowed…
mpg
  • 157
  • 1
  • 1
  • 10
10
votes
2 answers

sz and pwsz prefixes in WinAPI

I'm a little confused now with the hungarian notation prefixes in WinAPI for CHAR strings and WCHAR strings. When we use a CHAR string usually such a prefix is used: CHAR szString[] = "Hello"; We have a zero-terminated string szString so…
spandei
  • 219
  • 3
  • 16
1
2 3 4