Once upon a time, I was young and foolish and ignorant, and writing some code in Visual Basic. (Visual Basic 3. In 1994. Get off my back.) I learned that many people used this weird convention, where, say, a text control started with txt. txtName seemed kinda weird to me, since you knew the name entry box was probably a text control anyway, and besides, if you changed the type, you’d have to rename the variable EVERYWHERE it was used, even places where it didn’t matter what it contained, just that you were placing it somewhere. But I got used to it. Later I discovered that almost no one outside the windows programming community and not everyone within it used this style, finding it unnecessarily verbose.
Well, now I understand why it’s used so much. Sure it’s easy to tell what a variable’s type is from its function most of the time, but what if you have a huge array of redundant and overlapping types? Not so easy now, eh? i mean, the variable fileName is obviously a string. In C, char * or const char *, in regular C++ probably std::string (or maybe char * if you’re interfacing with C code). In Windows … hah. No such luck. It might be a char *, wchar_t * or TCHAR * (often referred to by typedefs like LPCTSTR, long pointer to C t_string), or it might be a std::string, or a BSTR or VARIANT string (or one of the wrapper classes like _bstr_t or _variant_t), or one of the higher level wrappers like CString, CComBstr, CComVariant, COleVariant, or in managed C++, the new .NET System::String.
Jesus christ in a handbasket.
And if you’re really unlike the source code you’ve inherited also has about 5 different custom string classes also that are interspersed with all of the above.