Newsgroups: comp.lang.c++.moderated
From: James Dennett <jdenn...@acm.org>
Date: 1 May 2001 11:11:32 -0400
Local: Tues, May 1 2001 11:11 am
Subject: Re: Hungarian notation
John Jacob wrote: Sad but true. > Hello, > I have been using c++ for a while, and mostly developed with MFC. After a > However, I keep seeing opinions that hungarian should not be used. [My comments apply to "Hungarian" notation as commonly used > What are the actual disadvantages of hungarian? in MFC etc., and not to smarter versions which encode only abstract type information.] It's a crutch for languages such as C which don't have such > Using hungarian does not It affects the person who wrote it by making them think > affect speed or stability, and does not affect the person who wrote it. too much in terms of implementation details, and not enough in terms of *meaning*. > Variable naming is done so that the NEXT person who writes Possibly; it can aid uniformity, but at the cost of absolute > finds it easier to understand the code. clarity. > So, does hungarian make code harder to maintain? As per by "vectorNames" example above, yes. Hungarian notation makes code harder to maintain. > Does it make code more Yes, because most of the types in good C++ code are not > difficult to read? primitive types, so you have to either (a) write a full type name in your Hungarian wart, making identifiers much longer for no gain, or (b) invent bizarre abbreviations for type names which are a barrier to entry for those wishing to read your code. Not to mention that it's not clear how Hungarian notation > Are there any alternatives to hungarian - seeing that just naming variables Maybe a meaningful name would avoid that: PathToConfigFile, > at random can cause problems (e.g where a name "file" would be used in a > single project to mean a handle to a file, a filepath, a CFile object etc.) ConfigFileStream, ... . I find that avoiding Hungarian notation helps me to concentrate on the meaning of my objects, where Hungarian notation leads people to name objects often solely based on their concrete type. The meaning is usually more resilient through changes than is the concrete type. -- James Dennett [ Send an empty e-mail to c++-h...@netlab.cs.rpi.edu for info ] You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||