A few days ago I was debating on how Indent Code ANSI / C and therefore whether it is possible to use the same style in different languages.
Obviously, the indentation is like the mother, each has his and extolled the benefits and you know: my mother did not touch!
Today, looking for information on wikipedia I came across this page: Indent Style where he discusses the most common techniques for indentation, here's a little summary:
* K & R style
//... x < 0 ) { if (x <0) ( "Negative" ) ; printf ( "Negative"); ; negative (x); { ) Else ( "Positive" ) ; printf ( "Positive"); ; positive (x); )
* Allman style (BSD in Emacs)
x == y ) while (x == y) ( something (); somethingelse (); ) finalthing ();
* BSD KNF style
x == y ) { while (x == y) ( something (); somethingelse (); ) finalthing ();
* Whitesmiths style
x == y ) while (x == y) ( something (); somethingelse (); ) finalthing ();
* GNU style
x == y ) while (x == y) ( something (); somethingelse (); ) finalthing ();
* Horstmann style
x == y ) while (x == y) ; (Something (); somethingelse (); //... x < 0 ) if (x <0) ( "Negative" ) ; (Printf ( "Negative"); ; negative (x); ) else ( "Positive" ) ; (Printf ( "Positive"); ; positive (x); ) ) finalthing ();
* Pico Style
stuff (n): (X: 3 * n; y: DoStuff (x); y + x)
* Banner Style
function1 () ( DoStuff do more stuff ) function2 () ( etc )
And what you use?
Posted under Technology
This post was written by admin on November 4, 2008







But the lack of language with the required indentation like Python ... or Cobol.
Configuration
Tab into spaces (hate the character \ t)
2 characters indentation
Styles
GNU Style for all code
Pico Style for short methods of boilerplate code (type setter / getter and the like)
GNU Style life, partly because I started with Pascal
BSD style for if / while and the like! Instead the body functions Allman style.
This instead as you call it? Is missing
if (condition) (
something ();
) Else (
something_else ();
)
Sometimes I use it.
Ops sorry, I had missed the first in list
Fix also the first to comment!
I am old, so K & R.
While the code tends to be too moved to the right ...
if (condition)
(
....
....
....
) Else (
....
....
....
)
K & R style