From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 109fba,f292779560fb8442 X-Google-Attributes: gid109fba,public X-Google-Thread: 10db24,30e368bdb3310fe5 X-Google-Attributes: gid10db24,public X-Google-Thread: 1014db,30e368bdb3310fe5 X-Google-Attributes: gid1014db,public X-Google-Thread: f8c65,30e368bdb3310fe5 X-Google-Attributes: gidf8c65,public X-Google-Thread: 103376,30e368bdb3310fe5 X-Google-Attributes: gid103376,public X-Google-Thread: 1008e3,30e368bdb3310fe5 X-Google-Attributes: gid1008e3,public X-Google-Thread: fac41,af40e09e753872c X-Google-Attributes: gidfac41,public From: willer@carolian.com (Steve Willer) Subject: Re: Hungarian notation Date: 1996/05/23 Message-ID: <31a3b322.442404233@sqarc>#1/1 X-Deja-AN: 156228535 sender: news@sq.com (News Administrator) references: <4adem2$b5s@mercury.IntNet.net> <4n6off$6e2@mikasa.iol.it> <3198F30F.2A2@zurich.ibm.com> <4nsg3f$liu@solutions.solon.com> organization: Carolian Systems, Toronto ON newsgroups: comp.lang.ada,comp.lang.c++,comp.lang.c,comp.lang.modula3,comp.lang.modula2,comp.edu,comp.lang.eiffel Date: 1996-05-23T00:00:00+00:00 List-Id: seebs@solutions.solon.com (Peter Seebach) wrote: >The problem is that now, you'll see code like > pZz->iSomething = 3; >Consider: Years later, you need to change this... You need to use >a function... So ZZ has a member > int (*pifFoov)(void); >which is always set roughly correctly, and we go to > #define iSomething (*(pifFoov)()) >or something similar. (I know, this isn't precisely right.) >Suddenly, the name is a blatant lie. Of course it is. So don't do that. If you really need to change the variable type, you can always do a search-and-replace. With my code, my HN prefixes are of fairly low detail and the names are usually descriptive (and unique), so on the rare times when I might change the type of a member, I just do a search and replace with no problems. Besides, let's say for the sake of argument that you're not using HN: myZ->Something = 3; First of all, I'll never remember that myZ is a pointer and Something is an int. I can't rely on my memory and I certainly can't rely on some other maintainer's ability to memorize my code. But that aside, what if you do need to change it to a function? How can you possibly avoid editing the calling code (unless you used that #define hack, which isn't even an option)? At the very minimum, you'd have to change it to myZ->Something() = 3; or myZ->Something(3); Either way, you have to change existing code, so I don't see the disadvantages of having HN in it already. The reason this doesn't bother me at all is that I don't use data members very often. At least with C++, my language, you're much better off to design your classes based on actions and queries, rather than direct data-exchange. The consequence of this is that member-variables aren't generally public. >How about this: Notate the following declaration correctly: > FILE *Foo; > >... Hmm. Maybe it's "pst". Nope, FILE may not be a struct. Maybe it's >"pch". Nope, file may not be a char, even though FILE * is often really >a pointer to char. ???? You're kidding, right? "FILE" is the struct used by the stdio functions. How can any function get a descriptor number from an array of chars? That issue aside...I would use the prefix "pf", as in "pointer to file". So my declaration would perhaps be: FILE *pfFoo; Seems pretty clear to me.