Hungarian notation bad
Hem / Teknik & Digitalt / Hungarian notation bad
Limited length of names didn't help either, so all those "ls_" had some significant advantages.
But times have changed. At first glance, identifiers using Hungarian Notation appear to be gibberish until the pattern is deduced. What's weird - prefixes are more required from the freshman than proper naming in general.
Because of the reasons above, one person in a program might use wa_ (making it unclear if the variable is local or global), while another uses ls_ or gs_.
However, giving up HN won’t noticably improve your code unless it’s part of a broader set of changes, including:
- Meaningful naming (without HN)
- Small routines (methods)
- Single responsibility
This short list is just the beginning, but following these three principles alone (along with giving up on prefixes) will significantly improve the quality and maintainability of your code.
If not HN, then which style should I follow?
What is gt_partner in this case? If the frist and last letters of a word are correct and the middle letters are slightly jumbled, we can still read it as if it were correct, sometimes without even notciing the errors 😉.
Common Type Prefixes
| b | by y | c | C | d | dw | f | g_ | h | I | l | m_ | n | p | s str | sz psz | u | v | w | x | X |
| Prefix | Meaning | Example | Notes | |||||||||||||||||||||||||||||||||||
| p | Pointer | In most cases, p is combined with another prefix; the prefix of the type of object being pointed to.
I know I’m looking for a table of customers, so I type "cus" and hit ctrl+Space. If it is not possible to abbreviate and the type name is not too long, you can just use the type name as a prefix. The Type Prefix will always be entirely lowercase and should reflect the name of the type by abbreviating it distinctively. In Systems Hungarian, the only thing that the prefix told you was the actual data type of the variable. Making Wrong Code Look Wrong:
Critique of Exceptions:
Key Takeaways
The article emphasizes the importance of making code visually intuitive and easy to debug, particularly for mission-critical applications[1][2]. OriginsThe notation was invented by Charles Simonyi, a Hungarian-born programmer who worked at Xerox PARC and later became Chief Architect at Microsoft. Sure, if you’re used to hieroglyphics, you can read them quickly, but it’s still much slower than reading a regular novel. As Uncle Bob once said, adding prefixes is like adding unnecessary code to the code itself. Now, I "search" for variables by their name, not their type.
More explanation about Hungarian notation .Your programs should clearly outline the purpose of the variable along with its declaration . Is it a field symbol, or a structure? There is a set of standard qualifiers for variables used in commonly performed programming tasks.
Top of table Type Prefixes for non-common TypesIn many cases, you will have identifiers of non-standard types. |