Quote:Original post by Giedrius
The variable isn't that likely to require a change of its kind, especially if it's already so widely spread.
Real world experience says otherwise.
Quote:And even if it is inevitably needed to change the kind of the variable, it is likely that the name would have to be changed anyway.
Which works great for a hobby project.
In practice, there will be multiple projects, each having dozens of branches, features back-ported, released DLLs in use by potentially millions of customers, all referencing same names, needing to support 5 year old files that have passed end of life, ....
API/interface is the single most expensive thing to change. This is why most APIs in heavy use are not updated, but deprecated, while features are always only added, never removed (looking at you Java).
Same goes for WinAPI. Layer upon layer of new concepts, but nothing ever removed.
And another C/C++ gotcha:
int i = (int)pFoo;
pFoo is pointer to foo, pointers are 32 bit, int is 32 bit. Works fine.
Except that Microsoft had to release extra training documents to discuss how all applications had to be patched, since pFoo was no longer same as pFoo, even if used in same application. Some of pFoos were now 64 bit, while others were 32 bit. Some were even 16 bit.
And while this could be fixed via p32Foo and p64Foo, it breaks elsewhere. Pointers need to be natively sized, so naming them p32 and p64 doesn't make sense - they will be whatever platform they are built on.
wchar_t - how many bytes? wstrlen expects wchar_t, yet size of wchar_t is up to compiler, so p2bwct (pointer to 2 byte wchar_t) isn't compatible with p4bwct (pointer to 4 byte wchar_t).
Hungarian notation has been proven as a falacy. The article linked before discusses on why the wrong one got adopted.