11

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 notation has fallen out of favor, I am seeing (at work, internet, etc.) a lot of data type indicators added as a 'suffix' to variable names, i.e.

NameStr = "Gonzo";        // String
NumberInt = 10;           // Integer
MyRideBike = new Bike();  // Bicycle

Is there a name for this, when the data type is suffixed to a variable name?

EDIT: To clarify..., is there a distinct name for such a thing? If not, some concise ideas on what to call it would certainly be appreciated.

A.R.
  • 15,405
  • 19
  • 77
  • 123

2 Answers2

15

This is not the opposite of Hungarian notation, this is Hungarian notation in a different guise, if we follow Stroustrup's definition of Hungarian notation as "embedding an abbreviated version of a type in a variable name". If you want to call it anything, call it suffix Hungarian. (And please tell your colleagues that it's useless in most cases.)

Fred Foo
  • 355,277
  • 75
  • 744
  • 836
  • The opposite of the beginning is the end. From the same article... "In Hungarian notation, a variable name starts with a group of lower-case letters ..." --> Meanwhile, we totally agree on the uselessness of the practice. – A.R. Sep 30 '11 at 12:25
  • 1
    But the opposite of putting the type in the name is not putting the type in the name, and whether it's a prefix or a suffix doesn't really matter. It's a convention that beats the purpose of type systems both static and dynamic. – Fred Foo Sep 30 '11 at 12:27
  • blah blah blah, If you think the title of the question is wrong then change it to something more suitable. – A.R. Sep 30 '11 at 12:36
  • My point is that this *is* Hungarian notation and there's no reason to call it anything else. – Fred Foo Sep 30 '11 at 12:41
  • 1
    Yeah, IF you follow 'Stroustrup's definition' 9999 out of 10000 people will talk about the prefix if you were to ask them to define Hungarian notation, and you know it. My point is that I am looking for a term that is distinct, rather than obscure. Kind of like how a square is a rectangle, but it has its own name to identify its special properties? – A.R. Sep 30 '11 at 13:22
  • By this logic BASIC requires the use of Hungarian notation... ;-) – R.. GitHub STOP HELPING ICE Nov 19 '11 at 04:46
  • Well according to the wikipedia page you link to "In Hungarian notation, a variable name **starts** with a group of lower-case letters which are mnemonics for the type or purpose of that variable". Additionally I think Stroustrup doesn't talk about placement because his point would be applicable regardless of where in the name the type indication was. – Alan Macdonald Nov 30 '11 at 22:21
11

I would call this reverse hungarian notation which would be consistent with the difference between polish notation and reverse polish notation.

Additionally billmcc's post on the following link shows real life usage of the term "reverse hungarian notation" What was the strangest coding standard rule that you were forced to follow?

Community
  • 1
  • 1
Alan Macdonald
  • 1,872
  • 20
  • 36