code style

Thread Starter

TAKYMOUNIR

Joined Jun 23, 2008
352
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
THANKS
 

t06afre

Joined May 11, 2009
5,934
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
 

John P

Joined Oct 14, 2008
2,026
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.
 

ErnieM

Joined Apr 24, 2011
8,377
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.
 

sceadwian

Joined Jun 1, 2009
499
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.
 

WBahn

Joined Mar 31, 2012
30,076
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.
 

THE_RB

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

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.
...
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.
 
Top