Best way to get rid of hungarian notation?

2020-04-07 04:47发布

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?

20条回答
爱情/是我丢掉的垃圾
2楼-- · 2020-04-07 05:51

Don't forget that there are two kinds of Hungarian Notation.

The original Charles Simonyi HN, later known as App's Hungarian and the later abomination called System Hungarian after some peckerhead (it's a technical term) totally misread Simonyi's original paper.

Unfortunately, System HN was propagated by Petzold and others to become the more dominant abortion that it is rightfully recognised as today.

Read Joel's excellent article about the intent of the original Apps Hungarian Notation and be sorry for what got lost in the rush.

If what you've got is App's Hungarian you will probably want to keep it after reading both the original Charles Simonyi article and the Joel article.

If you've landed in a steaming pile of System Hungarian?

All bets are off!

Whew! (said while holding nose) (-:

查看更多
我欲成王,谁敢阻挡
3楼-- · 2020-04-07 05:51

If you have a legitimate need to remove and change it I would use either the built in refactoring tools, or something like Resharper.

However, I would agree with Chris Conway to a certain standpoint and ask you WHY, yes, it is annoying, but at the same time, a lot of the time the "if it aint't broke done't fix it" method is really the best way to go!

查看更多
登录 后发表回答