| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Newbie code part 2 |
SL>Eric Weigel le escribe a Doug Glenn:
SL>EW> Compilers with type checking eliminate the need for
SL>EW> encoding variable types in the name.
SL>If I see BOBclient, I can immediately tell that it is a variable of
SL>type BOB that has something to do with a client. How can I otherwise?
SL>You can be clever and point out that some IDE's will tell you, for
SL>example, QuickBasic 4.5. (Was _that_ ever a long time ago! Too bad it
SL>was discontinued.) However, a piece of paper hasn't been capable of
SL>doing much since it was in the tree.
What is a BOB?
I don't have much problem with prefixing pointer names with "p", and
less with prefixing handles with "h". Same goes for typedefs, where for
instance PVOID is clear (but void* is clearer). HWND, HFILE, HAPP are
not only clear, but to my mind sensible.
The other problem with "Hungarian" notation is what happens when you
have to change the type of an existing variable or (really important!)
structure member. The meaning and usage may be identical, but now you
have to edit perhaps hundreds of lines of code.
The natural response will be to forget about renaming the thing, but
then you end up with a notation that does not describe reality. On the
other hand, you may decide that keeping the notation current is worth
it, and rename everything. But, you'll forget at least one.
OS/2 2.x header files are a fine example. Many things changed from
USHORT to ULONG in the transition from 1.x Most of them changed
their names, some didn't.
File PMDDI.H:
typedef struct _NOTIFYTRANSFORMDATA /* ntd */
{
ULONG usType;
<<<<<<<<<<<<<<<<<
XFORM xform;
} NOTIFYTRANSFORMDATA;
typedef NOTIFYTRANSFORMDATA *PNOTIFYTRANSFORMDATA;
File PMSTDDLG.H:
typedef struct _SEARCHSTRING /* srchstr */
{
ULONG cb;
PSZ pszSearch;
ULONG fsPrefix;
ULONG fsCaseSensitive;
ULONG usView;
<<<<<<<<<<<<<<<<<
} SEARCHSTRING;
typedef SEARCHSTRING *PSEARCHSTRING;
File pmwin.h:
typedef struct _WNDPARAMS /* wprm */
{
ULONG fsStatus;
<<<<<<<<<<<<<<<<<
ULONG cchText;
PSZ pszText;
ULONG cbPresParams;
PVOID pPresParams;
ULONG cbCtlData;
PVOID pCtlData;
} WNDPARAMS;
typedef WNDPARAMS *PWNDPARAMS;
typedef struct _CONVCONTEXT /* cctxt */
{
ULONG cb; /* sizeof(CONVCONTEXT) */
ULONG fsContext;
<<<<<<<<<<<<<<<<<
ULONG idCountry;
ULONG usCodepage;
<<<<<<<<<<<<<<<<<
ULONG usLangID;
<<<<<<<<<<<<<<<<<
ULONG usSubLangID;
<<<<<<<<<<<<<<<<<
} CONVCONTEXT;
typedef CONVCONTEXT *PCONVCONTEXT;
___
X SLMR 2.1a X
--- Maximus/2 2.02
* Origin: Bob's Bored/2 (1:244/440)SEEN-BY: 105/42 620/243 711/401 409 410 413 430 807 808 809 934 955 712/407 SEEN-BY: 712/515 628 704 713/888 800/1 7877/2809 @PATH: 244/400 250/702 3615/50 396/1 270/101 105/103 42 712/515 711/808 809 @PATH: 711/934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.