Skip to main content.
September 9th, 2005

Slowing going back.. to the future !

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

This entry was posted on Friday, September 9th, 2005 at 1:56 am and is filed under Uncategorized. You can follow any responses to this entry through the comments RSS 2.0 feed. You can leave a response, or trackback from your own site.

3 Responses to “Slowing going back.. to the future !”

  1. ragin' lion says:

    Oh dear … I can’t believe such positive comments about C++!!! You will be assimilated! 8P 頑張って下さい!

  2. Davide Pasca says:

    頑張ります!
    ehehe the famous rule of relativity (at the social level) applies here: I bashed C++ so much, that when I bring up a good point, even though it’s an indirect one, it seems like I’m praising the language !

    Cool 8)

  3. Pomy says:

    It’s a nice coding style. Unfortunately I’m so lazy that when I write a bean in java I want the IDE to generate the accessors by itself.
    But if you call private variables like

    int _var = 0

    When you generate the accessors you get

    int get_var()

    void set_var(_int var)

    I don’t like the _ in the name of the accessors!!

    ^____^

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>