Although recently I had the urge to go back to ‘C’.. I have to admit that there are some reasons to keep trying with C++. An important one is, ironically, not really a feature of the language, but rather a functionality that is now pretty much standard in every major IDE (Integrated Development Environment). In VisualStudio it’s called IntelliSense. It basically suggests the available methods for a certain class as code is being written.
This feature actually comes very handy, especially if one is using a class made by somebody else. This is often the case for most programmers as it’s implicit in the teamwork to have to use somebody else’s code.
It’s a feature or, more specifically, an aid, that can be considered part of the documentation, something that certainly can make it much simpler for others to try digest a library made by somebody else (cough cough)… I’ve always been very worried about the usability of my code, especially now that it’s hard to communicate with my coworkers (Japanese vs English: a matter of language but also of culture, as Japanese rarely speak out).
So basically, I feel like keeping onto C++, because it somewhat helps me some to write my own code, and can probably help a lot more those that one day may have to use my code.
Of course C++ still allows to write very obfuscated code.. and there comes the programmer’s ability not make a mess. For this, one can only rely on the good will and the experience of the programmer. Luckily, in my current company C++ seems to be used neatly. The C++ code that I’ve seen from the coworkers, seems rather well done, not filled with bullshit C++ tricks of the month. ..although I have a problem with some coding standards that have been set some time ago and that I truly think I’ll never want to adapt to (hint: underscore before every parameter and local variable !).
Speaking of coding standards, I’ve update mine with C++:
class MyClass // UpperLower style (most people just like it better !)
{
int _value; // Unix programming style variables
int _other_member; // underscore to avoid mixing up members with locals
public:
int GetValue(); // UpperLower again for public methods
void SetValue( int new_value );
private:
void updateSomething(); // lowerUpper for private methods
};
The logic behind:
- Classes and public methods need to be clearly visible, so the upper and lower style, with the capital in uppercase.
- It’s nice to be able to recognize at a glance private methods, so comes the capital lower-case. This way, they don’t jump to the eye as quickly as the public ones.
- Members and variables in general are lowercase, separated by underscore. It’s very readable to me and doesn’t make confusion with methods, functions, etc.
- Members need to be distinguished from other variables, so they start with an underscore. The popoular “m_” is a bit too distracting, while the underscore at the end of the member doesn’t stand out enough, and actually I just don’t like the stupid “tail” 8)
Goodnight !
Posted by Davide Pasca in Uncategorized
