+ 2
Hungarian Notation
Do you think there's any benefit of using Hungarian Notation for loosely typed languages? Is it still used? What is the sole purpose for using it? Are there any alternative conventions?
3 Antworten
+ 3
Naming conventions is more closely related to code formatting and uniformity I guess, it's hard to think of naming convention in relation to type system (weak, strong, static, dynamic etc.).
AFAIK hungarian notation is a way to describe an variable's type by using a certain prefix for the identifier (mostly variable names). But it may not be of any use in languages with dynamic type nature, cause in such languages, data type is deducted from the data being assigned (rather than explicitly specified) to the variable.
"Is it still be used, what's the sole purpose of using it, are there any alternative conventions?"
These are a bit opinionated type of questions, but perhaps this might help?
http://cws.cengage.co.uk/rautenbach/students/ancillary_content/hungarian_notation.pdf
+ 3
I remember one person here saying they use it for SQL column names so you know what the types are, without looking at the database schema. That sounded like a good use case.
I'm not a fan myself. The WinAPI for example uses hungarian notation but the types have changed a lot, so now all the variables are named wrong because renaming them would break code. But I'm also not a C programmer, though I haven't felt the need to prefix my javascript variables. I guess you'd prefix 90% of variables with "o" for object so there's no point really. Also I can just hit F12 and look up the type of a variable, so there's doubly no point. I guess tooling and IDEs weren't as good when hungarian notation was invented.
+ 1
Thanks.