Naming convention from my point of view

Discussion in 'C++' started by DEX, Apr 20, 2004.

  1. DEX

    DEX Guest

    DEX, Apr 20, 2004
    #1
    1. Advertising

  2. Claudio Puviani, Apr 20, 2004
    #2
    1. Advertising

  3. DEX

    bartek Guest

    bartek, Apr 20, 2004
    #3
  4. DEX

    Derek Guest

    DEX wrote:
    > Main page of my NC:
    > http://www.ddmrm.com/coding/cpp/naming/cpp.naming.main.html
    > Rules of my NC:
    > http://www.ddmrm.com/coding/cpp/naming/cpp.naming.rules.html
    >
    > Comments are welcome. ...


    Your convention is scary. It's Hungarian notation on steroids.

    Instead of:

    GI_a-> F1vc_b( &Pi_c );

    I would much rather see:

    pConnection->receiveMessage(&localMessageBuffer);

    Many C++ IDEs can tell me everything else at a glance, so
    there's no need to clutter my otherwise sensible names with
    obsufcated metadata that requires a decoder ring for a new
    developer to even begin to grasp.

    Just my $0.02.
    Derek, Apr 20, 2004
    #4
  5. DEX wrote:
    >
    > Main page of my NC:
    > http://www.ddmrm.com/coding/cpp/naming/cpp.naming.main.html
    > Rules of my NC:
    > http://www.ddmrm.com/coding/cpp/naming/cpp.naming.rules.html
    >
    > Comments are welcome. ...


    You made me think of two things that I find quite important in
    regards to naming:

    0) The famous rule of uniformity.
    Loosely put, things that look alike should behave alike; and
    the other way around, things that look different should behave
    differently. "Should" means "I expect them to".

    Normally, when I say
    ClassName obj;
    obj.f(a+b);

    I don't care about the types or constness of a and b, whether f() is
    virtual or not or whether ClassName is actually the name of a class or a
    typedef-specialisation of a class template, etc. I shouldn't care.
    This is why any sort of a la Hungarian notation hinders me, not helps,
    in understanding the code. Even "m_" for member variables is too much
    and too ugly for me. One notable exception is "p_" before pointer
    variable names; pointers are actually different to references in their
    syntax and behaviour.

    1) Name compactness or maximum of signal-to-noise ratio.
    Any extra decoration that is not readily intelligible makes the name
    harder to read and understand. The same goes for suffixing/postfixing
    that is recongisable but superfluous. Most of it is just noise to me.
    This doesn't sound like a big deal ("just ignore it"), but it is. It
    takes away a huge amount of energy in the form of concentration.

    Suffixing is still used for scoping in large projects, but C++ classes
    and namespaces have greatly reduced the need for it.

    Denis
    Denis Remezov, Apr 21, 2004
    #5
  6. DEX

    Jack Klein Guest

    On Tue, 20 Apr 2004 16:52:21 +0200, "DEX" <> wrote in
    comp.lang.c++:

    > Main page of my NC:
    > http://www.ddmrm.com/coding/cpp/naming/cpp.naming.main.html
    > Rules of my NC:
    > http://www.ddmrm.com/coding/cpp/naming/cpp.naming.rules.html
    >
    > Comments are welcome. ...


    Why should we care?

    But my comment is, I don't like it.

    --
    Jack Klein
    Home: http://JK-Technology.Com
    FAQs for
    comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
    comp.lang.c++ http://www.parashift.com/c -faq-lite/
    alt.comp.lang.learn.c-c++
    http://www.contrib.andrew.cmu.edu/~ajo/docs/FAQ-acllc.html
    Jack Klein, Apr 21, 2004
    #6
  7. DEX

    Alvaro Guest

    Denis Remezov wrote:

    > DEX wrote:
    >>
    >> Main page of my NC:
    >> http://www.ddmrm.com/coding/cpp/naming/cpp.naming.main.html
    >> Rules of my NC:
    >> http://www.ddmrm.com/coding/cpp/naming/cpp.naming.rules.html
    >>
    >> Comments are welcome. ...

    >
    > You made me think of two things that I find quite important in
    > regards to naming:
    >
    > 0) The famous rule of uniformity.
    > Loosely put, things that look alike should behave alike; and
    > the other way around, things that look different should behave
    > differently. "Should" means "I expect them to".
    >
    > Normally, when I say
    > ClassName obj;
    > obj.f(a+b);
    >
    > I don't care about the types or constness of a and b, whether f() is
    > virtual or not or whether ClassName is actually the name of a class or a
    > typedef-specialisation of a class template, etc. I shouldn't care.
    > This is why any sort of a la Hungarian notation hinders me, not helps,
    > in understanding the code. Even "m_" for member variables is too much
    > and too ugly for me. One notable exception is "p_" before pointer
    > variable names; pointers are actually different to references in their
    > syntax and behaviour.
    >
    > 1) Name compactness or maximum of signal-to-noise ratio.
    > Any extra decoration that is not readily intelligible makes the name
    > harder to read and understand. The same goes for suffixing/postfixing
    > that is recongisable but superfluous. Most of it is just noise to me.
    > This doesn't sound like a big deal ("just ignore it"), but it is. It
    > takes away a huge amount of energy in the form of concentration.
    >
    > Suffixing is still used for scoping in large projects, but C++ classes
    > and namespaces have greatly reduced the need for it.
    >
    > Denis


    I agree: prefixes and suffixes make code unreadable (I hate MS-Hungarian
    notation). Library prefixes are better substituted with namespaces. I don't
    even use p_ before pointers.

    The only convention I try to follow and find pleasing resembles that of
    Java:

    -Capitalized Class Names
    -lowercase variables and functions
    -uppercase preprocessor macros and enums
    Alvaro, Apr 21, 2004
    #7
  8. DEX

    DEX Guest

    DEX, Apr 23, 2004
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rick

    Which c# naming convention?

    Rick, Jan 19, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    3,772
    Paul Glavich
    Jan 19, 2004
  2. dm1608
    Replies:
    6
    Views:
    8,509
  3. Buck Turgidson

    JSP Method Naming Convention

    Buck Turgidson, Mar 2, 2004, in forum: Java
    Replies:
    1
    Views:
    1,747
    P.Hill
    Mar 2, 2004
  4. harry
    Replies:
    2
    Views:
    1,182
    harry
    Dec 8, 2004
  5. Saraswati lakki
    Replies:
    0
    Views:
    1,317
    Saraswati lakki
    Jan 6, 2012
Loading...

Share This Page