Mathematical
Silver Coder
Hey there.
So, we all know the debate about programming-styles in the world of programming and CS. Tabs vs spaces, braces on a new line or on the same line of a function/class, you get the idea. So, I figured, why not ask the CF community on what style they follow.
There are many well known styles in programming. Those being: K&R(Named after Brian W. Kernighan and Dennis Ritchie, creator of C, and both authors of The C Programming-Language, practically the Bible for all C programmers) and Allman Style(Named after Eric Allman, a programmer who wrote many utilities for *BSD). Of course, there are other styles such as GNU style(Named after the GNU Project, which was founded by free-software activist, Richard Stallman), and Horstmann Style(Named after Cay S. Horstmann, who has written and still continues to write many programming books).
But those are just the "indentation-styles". So, how you layout your braces, and how many spaces you insert, and whether you use tabs or spaces. I'd also like to know how you guys name and declare your variables, if you aim to make your code more compact or space it out several lines, and also how frequently you comment your code.
There is a poll in this thread that you can choose to vote on which style you use.
I myself personally, follow my own style. Here's my specifications:
Those right there, are my specifications for my own, preferred style of writing my code in. Feel free to punch it, kick it, or do whatever to it. Hell, even feel free to test it out for yourself to see if it's a style you like.
So, we all know the debate about programming-styles in the world of programming and CS. Tabs vs spaces, braces on a new line or on the same line of a function/class, you get the idea. So, I figured, why not ask the CF community on what style they follow.
There are many well known styles in programming. Those being: K&R(Named after Brian W. Kernighan and Dennis Ritchie, creator of C, and both authors of The C Programming-Language, practically the Bible for all C programmers) and Allman Style(Named after Eric Allman, a programmer who wrote many utilities for *BSD). Of course, there are other styles such as GNU style(Named after the GNU Project, which was founded by free-software activist, Richard Stallman), and Horstmann Style(Named after Cay S. Horstmann, who has written and still continues to write many programming books).
But those are just the "indentation-styles". So, how you layout your braces, and how many spaces you insert, and whether you use tabs or spaces. I'd also like to know how you guys name and declare your variables, if you aim to make your code more compact or space it out several lines, and also how frequently you comment your code.
There is a poll in this thread that you can choose to vote on which style you use.
I myself personally, follow my own style. Here's my specifications:
- 5-Spaces
- 100-Columns maximum
- Function/Class/Method braces on the same line they're declared; conditional-statements, arrays, loops, and structure braces go on their own line.
- Do not insert braces inside single-line bodies of loops and conditional-statements.
- Do not group operators and variable names together(E.g. Instead of
Var1==Var2
orNum1+=Num2
, I writeNum1 += Num2
andVar1 == Var2
). - All variable names are written in CamelCase(E.g. Instead of
int big_number
, I writeint Big_Number
). - I frequently comment my code(I don't only use multi-line comments all the time. C'mon folks, single-line comments have hears too!)
Those right there, are my specifications for my own, preferred style of writing my code in. Feel free to punch it, kick it, or do whatever to it. Hell, even feel free to test it out for yourself to see if it's a style you like.