Let's say you've inherited a C# codebase that uses one class with 200 static methods to provide core functionality (such as database lookups). Of the many nightmares in that class, there's copious use of Hungarian notation (the bad kind).
Would you refactor the variable names to remove the Hungarian notation, or would you leave them alone?
If you chose to change all the variables to remove Hungarian notation, what would be your method?
Some potential issues are: The Hungarian notation is redundant when type-checking is done by the compiler. Compilers for languages providing strict type-checking, such as Pascal, ensure the usage of a variable is consistent with its type automatically; checks by eye are redundant and subject to human error.
In general, Hungarian Notation has fallen out of fashion. In strongly-typed languages, it's broadly redundant, especially the Systems Hungarian type. It can also make code more difficult to read. Any problems it might help solve are often signs of deeper flaws, such as an over-reliance on global variables.
Hungarian Notation (HN) is a naming convention that was originated years ago by Charles Simonyi of Microsoft and is used throughout the source code of the Windows operating system, among other places.
In Systems Hungarian notation, the prefix represents the actual data type of the object. For instance, if the object named Greeting were a zero-terminated string, its Systems Hungarian name might be szGreeting. Or, if the object YesOrNo were a boolean variable, its Systems Hungarian name would be bYesOrNo.
Refactor -- I find Hungarian notation on that scale really interferes with the natural readability of the code, and the exercise is a good way of getting familiar with what's there.
However, if there are other team members who know the code base you would need consensus on the refactoring, and if any of the variables are exposed outside of the one project then you will have to leave them alone.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With