Like Tree1Likes
  • 1 Post By GReaper

What are good naming conventions?

This is a discussion on What are good naming conventions? within the C Programming forums, part of the General Programming Boards category; Usually the best coding convention is consistency with surrounding code. But when you're writing something from scratch, what are some ...

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    2

    What are good naming conventions?

    Usually the best coding convention is consistency with surrounding code.

    But when you're writing something from scratch, what are some good naming conventions?

    For instance:

    • How do you format your variables? E.g. under_score_names, or CamelCase
    • Do you use prefixes for structs, pointers or typdefs? E.g. mytype_t, or pMyPointer
    • What kind of prefixing do you use to group functions together?

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,310
    Quote Originally Posted by marek.
    How do you format your variables? E.g. under_score_names, or CamelCase
    The former, but camel case is good too. As you noted, this is about picking a convention and then being consistent.

    Quote Originally Posted by marek.
    Do you use prefixes for structs, pointers or typdefs? E.g. mytype_t, or pMyPointer
    Generally, no.

    Quote Originally Posted by marek.
    What kind of prefixing do you use to group functions together?
    The library name, or an abbreviation thereof.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,159
    Are you just fishing for a flame war? There's strong preferences by some that get heated to the point of something akin to a religious war. Not one argument has more merit than the other, but everyone's got their oh-so-important preference. A quick google search will reveal just how absurd these discussions can get.

    The truth is, it doesn't matter what convention you use as long as you're consistent throughout the program. Just be careful to avoid reserved names and prefixes, and try to use meaningful names.
    If you understand what you're doing, you're not learning anything.

  4. #4
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    1,616
    Quote Originally Posted by itsme86 View Post
    The truth is, it doesn't matter what convention you use as long as you're consistent throughout the program. Just be careful to avoid reserved names and prefixes, and try to use meaningful names.
    +2

    See attachment
    Attached Images Attached Images  
    TheBigH likes this.
    Devoted my life to programming...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. In a game Engine...
    By Shamino in forum Game Programming
    Replies: 28
    Last Post: 02-19-2006, 10:30 AM
  2. Good books for learning WIN32 API
    By Junior89 in forum Windows Programming
    Replies: 6
    Last Post: 01-05-2006, 04:38 PM
  3. Good resources for maths and electronics
    By nickname_changed in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 12-22-2004, 03:23 PM
  4. what is good for gaphics in dos
    By datainjector in forum Game Programming
    Replies: 2
    Last Post: 07-15-2002, 03:48 PM
  5. i need links to good windows tuts...
    By Jackmar in forum Windows Programming
    Replies: 3
    Last Post: 05-18-2002, 11:16 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21