why is it that most older programmers use this style
if(bla){
do this
}
and not this
if(bla)
{
do this
}
i’m only in my second year now but i find that any time i get some sample code i have edit the style to it’s like the second way. the older style makes it harder to see where all the indentation is. just my €0.02
What you need is a copy of “indent” (indent -bls) and make your computer do the formatting the way you like it.
I think your way of using brackets is a waste of screen space and makes code much less readable. Much like giving function parameters their own line. But luckily there is indent…
It’s easier to grep lines which have { to see what they are for, when the statement for which the block is for is in on the same line.
then again, I suppose it behooves the question why do i want ot grep those lines??
Consider a very large block with lots of nested blocks. In one shot i can grep all the inside blocks to just get an idea of what goes on in there.
for eg.
statement {
…
…
statement2 {
….
…
} //statement2
} //statement1
now when i grep for {
i get
statement1 {
statement2 {
If u use ur indentation right u can very easily get the structure of the blocks. Heck i can get the entire structure of a program this way using a simple grep.
Atleast this is the reason why I have always used this style. I don’t claim to know why other ppl do that!!! All i need is a decent text editor (I like both vi and emacs!!). And I am not that old ), so plz no jokes about only old programmers using that style.
I usually to put the { in the next line in cases where i was using a block for its own purpose u know not as a part of a for/if etc.
for eg.
/*This block of code does something*/ {
}
Oops even then it is in the same line as the comment.
In modern ides i guess there is no need for this, and keeping the braces in the next line does may make it look prettier in a sense (may be its just a case of the grass being greener on the other side on my part!!)> But i like jidea it seems to automatically follow the old method .
Each to his own poison i guess, and also depends on what ur organisation policy is. In my org. we are supposed to code using the braces in the next line so i follow that. It’s as simple as that.
why is it that most older programmers use this style
if(bla){
do this
}
and not this
if(bla)
{
do this
}
i’m only in my second year now but i find that any time i get some sample code i have edit the style to it’s like the second way. the older style makes it harder to see where all the indentation is. just my €0.02
I think this is a matter of preference. For me the first works better. I consider the second _very_ ugly.
Many do it save lines… I like the second because the two brackets being aligned helps emphasize where the segment starts and ends.
I’m a new programmer and I prefer the old style, so there.
ignore me, 29 hours no sleep
;p
What you need is a copy of “indent” (indent -bls) and make your computer do the formatting the way you like it.
I think your way of using brackets is a waste of screen space and makes code much less readable. Much like giving function parameters their own line. But luckily there is indent…
It’s easier to grep lines which have { to see what they are for, when the statement for which the block is for is in on the same line.
then again, I suppose it behooves the question why do i want ot grep those lines??
Consider a very large block with lots of nested blocks. In one shot i can grep all the inside blocks to just get an idea of what goes on in there.
for eg.
statement {
…
…
statement2 {
….
…
} //statement2
} //statement1
now when i grep for {
i get
statement1 {
statement2 {
If u use ur indentation right u can very easily get the structure of the blocks. Heck i can get the entire structure of a program this way using a simple grep.
Atleast this is the reason why I have always used this style. I don’t claim to know why other ppl do that!!! All i need is a decent text editor (I like both vi and emacs!!). And I am not that old ), so plz no jokes about only old programmers using that style.
I usually to put the { in the next line in cases where i was using a block for its own purpose u know not as a part of a for/if etc.
for eg.
/*This block of code does something*/ {
}
Oops even then it is in the same line as the comment.
In modern ides i guess there is no need for this, and keeping the braces in the next line does may make it look prettier in a sense (may be its just a case of the grass being greener on the other side on my part!!)> But i like jidea it seems to automatically follow the old method .
Each to his own poison i guess, and also depends on what ur organisation policy is. In my org. we are supposed to code using the braces in the next line so i follow that. It’s as simple as that.
i use this style and works both to save a line and also to align the brackets…
if(bla)
{ do this
then do this
Do this too
}