Thread: C Etiquette Question

  1. #16
    Registered Abuser
    Join Date
    Jun 2006
    Location
    Toronto
    Posts
    591
    Also, another point of contension, especially for function naming, is CamelCase vs camelCase; I prefer the latter, but you'll find others (especially Windows programmers) not so much.

    Quote Originally Posted by master5001 View Post
    Is it? Now I know why one of my coworkers started blushing when I refered to her camel toe style. Thanks for clearing that one up, Todd.
    Sexual Harrasment Panda is on his way.

  2. #17
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    I have (in my personal projects) the conventions to use camelCase for private member functions, and CamelCase for public ones. At one point in the past, I actually used CamelCase to indicate "void" functions and camelCase to indicate "functions that return something".

    The key is consistency within the project, however, rather than some random "I felt like doing it this way today, and tomorrow I will do it differently".

    On a professional level I have worked in all sorts of environments - camel-case, no camel-case, underscore to separate parts of names, no underscore, prefix to indicate types or belonging, etc. That's what you get from 20 years of working in programmer/software engineering type jobs... :-)

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #18
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Well played. I see you pulling some fancy moderator style topic shifting. Which is peculiarly administrative for a non-moderator.

    I like camel-case for the most part. Though as you and others have mentioned really the project is what should drive the convention you use, not what you think looks best. Afterall, camel-case does not seem too visually appealing when the rest of the project uses underscore separation.

  4. #19
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    On my current project (not mine...), I'm forced to use CamelCase for functions, and underscores for variable names :\. Kinda sucks bad.

    For example (including a horrid brace style, tabs of 2 & ifs crammed on 1 line);
    Code:
    int FooBarIsCool(int * something_passed_in) {
      if(!something_passed_in)  return 0;
      *something_passed_in = 20;
      return *something_passed_in;
    }
    matsp, does it not annoy you when you have to work with "odd" styles?

  5. #20
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    I like tabs of two... But man the if statement issue is a little nasty... Why is that preferred? Or is it just required for one the iff statements have only one line following the condition?

  6. #21
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Just for if statements with one line... but it is horrid. I prefer tabs of 3, but meh. I have no idea why it was preferred, the project was started a few years ago when the creator had (less than he does now) knowledge of C. But he says there is too much code to change, which is 90% true .

    It's not uncommon to see:
    Code:
    int x;
    (void)FooBarIsCool(&x);
    And a lot of "odd" casts. Including casting NULL to other things, eg:
    Code:
    FooBarIsCool((int *) NULL);

  7. #22
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Find and replace can do some amazing things.......... I mean wow... In my brutally honest opinion is is significantly less work to have find and replace change all the "if(condition == true) whatever;" than it would be to write code all crazy to begin with. But whatever, sometimes you have to bite the bullet and just bend over in the name of a pay check.

  8. #23
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by zacs7 View Post
    matsp, does it not annoy you when you have to work with "odd" styles?
    Well, yes, but if you are that bothered by it, it's probably best to remain a hobby programmer (or run your own company, but that's much harder than not being a professional programmer). Unfortunatlely if you want to make money in a longer term, you have to please your employer.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 01:47 AM