oestandards icon indicating copy to clipboard operation
oestandards copied to clipboard

Hungarian notation is bad practice

Open lievendf opened this issue 8 years ago • 2 comments

In your guidelines you're using Hungarian notation (adding a prefix to variables to indicate their type). This is a practice that has long been rendered obsolete and counter productive. Why should you have a cDescription or iNumberOfOrders instead of description or numberOfOrders? What could description possibly be other than a string? And why should you care? A good name for a variable is enough to know what you're dealing with, if you need to know this at all...

lievendf avatar Sep 21 '17 13:09 lievendf

Your examples are, apparently, a bastardization of a pretty reasonable idea. See https://www.joelonsoftware.com/2005/05/11/making-wrong-code-look-wrong/

tl;dr You're supposed to prefix with the kind of thing it is, not its type. Is it unserialized? Unsafe?

bitwombat avatar Sep 01 '18 05:09 bitwombat

Like @LievenDeFoor said, it's Hungarian notation. Idea here is actually prefix type and in few cases kind (global vs parameter vs local) of variable to make code more readable. Not everybody moved to OE Development Studio (it helps there too), some people still use Progress Editor, some people make changes using mpro and it actually helps a lot to see what type/kind of variable you work with without scrolling back and forth. In most cases good variable name is all you need, but when you work with large teams it helps to keep code cleaner (and code review simpler) as everybody know how to prefix variable, not everybody can come up with good, short and meaningful variable name (as example lastModifiedDate is it DATE, DATETIME or DATETIME-TZ or formatted string?).

alextrs avatar Sep 02 '18 02:09 alextrs