code style

Discussion in 'Programmer's Corner' started by TAKYMOUNIR, Sep 19, 2012.


    Thread Starter Active Member

    Jun 23, 2008
    which code style is the best(Pico style,Banner style,Horstmann style,GNU style,Whitesmiths style,BSD KNF style,Allman style or K&R style)
    i use GCC COMPILER
  2. t06afre

    AAC Fanatic!

    May 11, 2009
    I prefer to use the Allman style my self. But in some cases i prefer to use 2 indents not 4. I do not think it has much to say as long as you stick to one style
    TAKYMOUNIR likes this.
  3. John P

    AAC Fanatic!

    Oct 14, 2008
    Allman style here too (I had to look up what that actually means). I like the way the braces line up with each other: it helps me remember what level I'm at among loops and if statements.
    TAKYMOUNIR likes this.
  4. t06afre

    AAC Fanatic!

    May 11, 2009
    He he I guess we all have adopted some coding indent style, perhaps without using a name on it. Here is a list of most of them
    TAKYMOUNIR likes this.
  5. DumboFixer

    Active Member

    Feb 10, 2009
    I tend to use whatever the coding standards of my employer say I must use :)
    sceadwian and ErnieM like this.
  6. t06afre

    AAC Fanatic!

    May 11, 2009
    Kind of hard to argue on those terms I guess ;) When in Rome, do as the Romans do
    sceadwian likes this.
  7. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    After I also looked it up I noticed I use the Allman style myself.

    I believe my white space is as important as comments in understanding the flow of code.
    TAKYMOUNIR likes this.
  8. sceadwian

    New Member

    Jun 1, 2009
    Look up the word style in a dictionary and compare it to your concept of style for a specfific purpose. -You'll always find someone that thinks they have something that is the best, and this is irrelevent to finding out what works for you, style is in the variation, not what is 'best' for a specific circumstance.
  9. WBahn


    Mar 31, 2012
    I strongly prefer the Allman, though I developed it completely independently and didn't know it had a name until about five minutes ago! I was originally taught using the K&R style and got fed up always trying to track down mismatched braces. So on about my third program I started aligning them and got docked for not following the style that was presented. I explained why I preferred the way I was doing it to the instructor and got all the points back and never lost any more for it, even though it made it harder for him to grade my code since it looked 'funny' and therefore 'wrong' to him.

    If you are going to be working on a given code base with others for an extended period of time, or on an extensive code base that already exists and will survive you, then there is a huge advantage to adopting the dominant style of that code base (or of agreeing to a style amongst the people contributing to the codebase) even if it is uncomfortable for you. If it's too painful, then develop some simple scripts to translate back and forth between the two styles.
  10. panic mode

    Senior Member

    Oct 10, 2011
    i strongly prefer all woman but that's another story. looks like i'm using GNU style.
  11. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    Doggie style... Oh hang on, what are we talking about again? :eek:

    Typical! Those that can, do. Those that can't... Give bad marks to students who are better than them.

    I started coding in K&R style, simply because it was more vertically dense, and monitors in those days had 25 text lines vertically. After collaborating with another programmer a year or so and he used "Allman style" it started to become pretty obvious that his code was definietly easier to read and make sense of complex branch structures. C is weak (well messy at least) in program flow and anything that makes it much easier to read is a significant benefit. Since then I have used that style.

    Even these days with colour syntax code editors and auto bracket pair highlighting etc it still makes it MUCH easier to read when the bracket pair are nicely aligned.