View Poll Results: What coding styles? [tick as many as you like]

Voters
46. You may not vote on this poll
  • K&R (bracket on same line as if but not for functions)

    10 21.74%
  • GNU (crazy indentation style)

    1 2.17%
  • Allman (brackets on their own lines)

    33 71.74%
  • Whitesmiths (completely retarded do not tick)

    1 2.17%
  • Hungarian Notation

    0 0%
  • Non-Hungarian notation (stupid microsoft).

    1 2.17%

Thread: Coding style?

  1. #16
    root
    Join Date
    Sep 2003
    Posts
    232
    >uh... I said "clearer", as in better than just indenting.
    Joke...funny...laugh. One of the biggest problems I see is that most people around here don't have a sense of humor when it comes to computers. You guys are missing out on the best part.

    >//is second line part of a block? or what?
    Well, simply by looking up and to the right a bit you'll see an opening brace and have your question answered.
    The information given in this message is known to work on FreeBSD 4.8 STABLE.
    *The above statement is false if I was too lazy to test it.*
    Please take note that I am not a technical writer, nor do I care to become one.
    If someone finds a mistake, gleaming error or typo, do me a favor...bite me.
    Don't assume that I'm ever entirely serious or entirely joking.

  2. #17
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    but the question is about positioning. looking up and to the right is not in line with the line of code in question. Having it up there does nothing more than hide it.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  3. #18
    root
    Join Date
    Sep 2003
    Posts
    232
    >looking up and to the right is not in line with the line of code in question.
    Can you honestly say that this is a problem? The only way I can imagine that it would be is if you're using a line based editor that only lets you see one line at a time, or if the line in question is really long and the brace is way out in the ionosphere where nobody could possibly see it. The latter is obviously too long and should be made shorter, the former is so uncommon it's scary.

    Last I checked, the eye move operation was very cheap.
    The information given in this message is known to work on FreeBSD 4.8 STABLE.
    *The above statement is false if I was too lazy to test it.*
    Please take note that I am not a technical writer, nor do I care to become one.
    If someone finds a mistake, gleaming error or typo, do me a favor...bite me.
    Don't assume that I'm ever entirely serious or entirely joking.

  4. #19
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    I never said it was a problem. Only that the start of a block having the same indent as the rest of the block makes it easier and faster to recognize as a block. We're talking about coding style here, not armageddon.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  5. #20
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,212

  6. #21
    Senior Member joshdick's Avatar
    Join Date
    Nov 2002
    Location
    Phildelphia, PA
    Posts
    1,146
    Ya know, despite my deeply held beliefs regarding how code should be formatted, I'm still going to have to code however my professor or employer wants me to. Sad but true.
    FAQ

    "The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.

    "If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.

  7. #22
    Registered User glUser3f's Avatar
    Join Date
    Aug 2003
    Posts
    345
    >looking up and to the right is not in line with the line of code in question.
    No need to look up to the right, just look down, I don't type stuff like:
    Code:
    if (var)
        doSomething();
    it's always:
    Code:
    if (var) {
        doSomething();
    }
    The first is error-prone.

    As for Hungarian notaion, I use it for scope, not for variable types:
    m for member
    s for static
    g for global (I rarely use globals though)

    I can't stand stuff like:
    class CFont;
    int nCount;
    LPSTR lpszName;
    grr just thinking of those examples ...

  8. #23
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    well in spite of the outspoken minority here, it looks like Allman is most popular as I expected. Whitesmiths even got a vote. Curious. My company uses that. I'm not a big fan of it, but its better than K&R
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  9. #24
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,212
    I also think hungarian notation is retarded. You should know what all your variables are anyway, and you should only have a few of them per function.

  10. #25
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    hungarian notation is indeed retarded. Knowing what all your variables are might be asking a bit much though. A few per function, yes. I agree. But there is the matter of globals, statics and members. I like the m_ notation as well as the g_ and s_. When it comes to types though I think that it is just stupid.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  11. #26
    I don't know what the different style names are. I'll give some examples and see what you guys think.

    [code]
    // Functions
    int main(int argc, char** argv)
    {
    DoSomething(true, 5, 0.6f);
    int MyVariable;
    for (int i=0; i<5; i++)
    {
    KillACat();
    }

    return 0;
    }

  12. #27
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,212
    Originally posted by FillYourBrain
    hungarian notation is indeed retarded. Knowing what all your variables are might be asking a bit much though. A few per function, yes. I agree. But there is the matter of globals, statics and members. I like the m_ notation as well as the g_ and s_. When it comes to types though I think that it is just stupid.
    which is why you avoid globals.

  13. #28
    Registered User
    Join Date
    Jan 2003
    Posts
    648
    /me hugs globals

    globals rock especially in games. makes things easier where unneeded encapusulation and $$$$ where it should be make things harder.

  14. #29
    I only declare classes global. Everything else I use is either inside a function or in the classes. I try to stay away from variables stored in functions if it's not a waste of RAM

  15. #30
    Board Conservative UnregdRegd's Avatar
    Join Date
    Jul 2003
    Posts
    154
    Behold: the one true coding style!
    Code:
    #include <iostream>
    using
          namespace std;
    
    int main
            ()    {
            cout << "Hello "
                 << "world?"
                 << endl;
    
        return 0; }
    If this unique coding style needs a name, call it Unregisteredianoregisteredian.
    I am a programmer. My first duty is to God, then to nation, then to employer, then to family, then to friends, then to computer, and finally to myself. I code with dignity, honor, and integrity.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Is it bad style of coding ??
    By noobcpp in forum C++ Programming
    Replies: 15
    Last Post: 11-06-2008, 10:39 AM
  2. Your Coding Style?
    By Krak in forum A Brief History of Cprogramming.com
    Replies: 45
    Last Post: 06-02-2005, 08:19 AM
  3. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM
  4. Coding style
    By Clyde in forum A Brief History of Cprogramming.com
    Replies: 21
    Last Post: 04-09-2002, 04:22 PM
  5. coding style
    By ActionMan in forum Linux Programming
    Replies: 1
    Last Post: 10-03-2001, 07:36 AM