1

I'm using the HNC in this way for variables in PHP: $p_nId. p stands for parameter, so the scope of the variable, n for the type (though PHP is loosely typed, it gives some structure), so numeral here. Is there a type prefix in the HNC for a mixed type as well?

  • What does "mixed type" mean in this context? That the variable can be of *any* type? – IMSoP Mar 16 '13 at 11:24
  • @IMSoP Yes, does it actually mean something else? I indeed mean it can be of any type - sorry for any misunderstanding. –  Mar 16 '13 at 11:25
  • Ok, just seemed odd to use HN to indicate that you *don't* know the type. I'm also not sure there's a standard for such things, so the answer may be "if you want there to be" – IMSoP Mar 16 '13 at 11:42
  • @IMSoP okay, that seems legit. You can add it as an answer and I'll accept it unless someone comes up with a standard. –  Mar 16 '13 at 12:01

1 Answers1

1

As far as I know, there is no standard set of abbreviations for Hungarian Notation, so you can just decide on your own (ensuring they are documented appropriately, of course!)

You may want to think carefully about what you want to indicate in your notation, however, rather than thinking in terms of base data types. For instance, an ID may be an integer, but $foo = $id +10 isn't likely to be a meaningful operation, so a HN which captures this distinction may be more useful.

Where you have a "mixed type" variable, it's likely that you actually know that it is one of a limited set of types - either a string or an array, say, but never a number or object. In that case, perhaps your HN should capture that information, rather than simply labeling the variable as "type unknown".

Edit: I just found a link to Charles Simonyi's original paper outlining the concepts, and skimming through I see that he does indeed suggest types should be related to their use, not their representation:

The test for type equivalence is simple: could the same set of operations be meaningfully applied to the quantities in questions? If so, the types are thought to be the same. If there are operations that apply to a quantity in exclusion of others, the type of the quantity is different.

IMSoP
  • 89,526
  • 13
  • 117
  • 169