Do people use the Hungarian Naming Conventions in

2019-01-17 14:27发布

Is it worth learning the convention or is it a bane to readability and maintainability?

20条回答
劫难
2楼-- · 2019-01-17 14:58

I don't use a very strict sense of hungarian notation, but I do find myself using it sparing for some common custom objects to help identify them, and also I tend to prefix gui control objects with the type of control that they are. For example, labelFirstName, textFirstName, and buttonSubmit.

查看更多
够拽才男人
3楼-- · 2019-01-17 14:59

Isn't scope more important than type these days, e.g.

  • l for local
  • a for argument
  • m for member
  • g for global
  • etc

With modern techniques of refactoring old code, search and replace of a symbol because you changed its type is tedious, the compiler will catch type changes, but often will not catch incorrect use of scope, sensible naming conventions help here.

查看更多
贪生不怕死
4楼-- · 2019-01-17 15:00

Sorry to follow up with a question, but does prefixing interfaces with "I" qualify as hungarian notation? If that is the case, then yes, a lot of people are using it in the real world. If not, ignore this.

查看更多
老娘就宠你
5楼-- · 2019-01-17 15:01

I still use Hungarian Notation when it comes to UI elements, where several UI elements are related to a particular object/value, e.g.,

lblFirstName for the label object, txtFirstName for the text box. I definitely can't name them both "FirstName" even if that is the concern/responsibility of both objects.

How do others approach naming UI elements?

查看更多
SAY GOODBYE
6楼-- · 2019-01-17 15:02

I've been working for IBM for the past 6 months and I haven't seen it anywhere (thank god because I hate it.) I see either camelCase or c_style.

thisMethodIsPrettyCool()
this_method_is_pretty_cool()
查看更多
倾城 Initia
7楼-- · 2019-01-17 15:03

What's wrong is mixing standards.

What's right is making sure that everyone does the same thing.

int Box = iBottom * nVerticleSide
查看更多
登录 后发表回答