Thread: hungarian notation

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jan 2007
    Posts
    330

    hungarian notation

    Is hungarian notation still used a lot in modern code or is it slowly weeded out?

    I thought it was not so useful anymore in modern typed languages and with all the OO and generic coding paradigms these days but it seems some programmers still cling to it.

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    I still see it quite frequently in the project I'm working on, though we try to avoid it. We do use a modern OO language (ActionScript) but we do a lot of work with a Java back-end, and so types aren't always what they should be. Purposes can also be obfuscated - so we'll include that information in the names as we go. There's probably a better solution - but you have to build on what you're given sometimes.

  3. #3
    The Right Honourable psychopath's Avatar
    Join Date
    Mar 2004
    Location
    Where circles begin.
    Posts
    1,071
    Quote Originally Posted by KIBO
    hungarian notation
    *vomits*
    M.Eng Computer Engineering Candidate
    B.Sc Computer Science

    Robotics and graphics enthusiast.

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >Is hungarian notation still used a lot in modern code or is it slowly weeded out?
    Real Hungarian or the misinterpreted and bastardized Hungarian that was a stupid idea from day one?
    My best code is written with the delete key.

  5. #5
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by Prelude View Post
    >Is hungarian notation still used a lot in modern code or is it slowly weeded out?
    Real Hungarian or the misinterpreted and bastardized Hungarian that was a stupid idea from day one?
    Can you give examples of both?

    I use only a couple notations regularly like:
    pVariable - for pointers
    m_Variable - for member variables

    Other times I might use others to distinguish variables with similar names, but I don't use the ugly stuff like: lpszStr...
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  6. #6
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    Quote Originally Posted by KIBO View Post
    Is hungarian notation still used a lot in modern code or is it slowly weeded out?

    I thought it was not so useful anymore in modern typed languages and with all the OO and generic coding paradigms these days but it seems some programmers still cling to it.
    Prepare to meet a lot of it. Not in new code, but in old code. Working code doesn't get replaced overnight just because someone invented a new shiny $buzzword technique. The reason for using hungarian notation is mostly gone and it will slowly fade out. But slowly. As in decades.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  7. #7
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by cpjust
    Can you give examples of both?
    She's probably talking about the difference between Apps Hungarian and Systems Hungarian. In my opinion, Apps Hungarian is mainly just a uniform way of abbreviating variable names, whereas Systems Hungarian is mainly a way to insist that the type system is useless.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  8. #8
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    Quote Originally Posted by KIBO View Post
    Is hungarian notation still used a lot in modern code or is it slowly weeded out?

    I thought it was not so useful anymore in modern typed languages and with all the OO and generic coding paradigms these days but it seems some programmers still cling to it.
    I still use it, but not religiously. I ge3neralyl use it when I'm modifying someones coede that already used it, like some of the examples on MSDN, or if the type is vitlly important to the code, such as large memory realignment operations. It's definatley useful tyo learn it and learn to use it so when you see it in code it doesnt break your rythym.

  9. #9
    Making mistakes
    Join Date
    Dec 2008
    Posts
    476
    I never use it and never used it. Meaningful names can actually save you a lot of time.

  10. #10
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    She's probably talking about the difference between Apps Hungarian and Systems Hungarian
    I often hear people refer to
    Code:
    excessively_long_overly_descriptive_variable_names
    as "hungarian notation". Maybe she means that.

  11. #11
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901
    I like descriptive and concise names, although it's often harder to pull out of the top of your had than hungarian notation.

  12. #12
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by indigo0086 View Post
    I like descriptive and concise names, although it's often harder to pull out of the top of your had than hungarian notation.
    I don't think Hungarian Notation and descriptive names are mutually exclusive. Hungarian Notation is just a prefix to a variable name. So you could have something like:
    lpszFirstName
    which is perfectly descriptive, albeit ugly to look at.
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  13. #13
    Registered User
    Join Date
    Apr 2008
    Posts
    890
    Quote Originally Posted by cpjust View Post
    I don't think Hungarian Notation and descriptive names are mutually exclusive. Hungarian Notation is just a prefix to a variable name. So you could have something like:
    lpszFirstName
    which is perfectly descriptive, albeit ugly to look at.
    Until you decide it should be a std::string, then it's a liar.

  14. #14
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by medievalelks View Post
    Until you decide it should be a std::string, then it's a liar.
    That's why I don't use Hungarian Notation for variable types, just the more common notations like m_ for member variables & p for pointers.
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  15. #15
    Making mistakes
    Join Date
    Dec 2008
    Posts
    476
    Hungarian notation is like lpwszStr (which is a long pointer to a wide zero-terminated string) or lphwndHandle (of type long pointer to window handle). Certainly, I'm exaggerating a bit. Nobody would propably need a lphwndHandle.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. CamelCase VS Hungarian notation, which is better?
    By meili100 in forum C++ Programming
    Replies: 4
    Last Post: 04-22-2007, 09:31 PM
  2. Hungarian Notation
    By FOOTOO in forum C Programming
    Replies: 6
    Last Post: 05-20-2005, 08:35 PM
  3. Hungarian Notation POLL
    By maxhavoc in forum A Brief History of Cprogramming.com
    Replies: 13
    Last Post: 06-21-2004, 10:52 AM
  4. hungarian notation
    By confuted in forum C++ Programming
    Replies: 2
    Last Post: 07-28-2003, 01:19 PM
  5. Hungarian Notation
    By gamegod3001 in forum A Brief History of Cprogramming.com
    Replies: 24
    Last Post: 10-13-2001, 11:17 AM