Code style
-
i've been chatting with the new guy at work today and he respectfully informs me he can't recall the last time he saw this notation: private void foo() { //statements } and contends that almost always people use: private void foo() { //statements } which to me is a total waste of a linebreak and less readable. worse still, the other new dude concurs? whassup with that? being a fan of the former notation, it seems to me that either the new generation of coders are being being taught different, or the old ones are getting too anal about space. my question is... what in fact is the standard? perhaps we should have a poll on CodeProject and settle this once and for all!
I've always, in the 12 or so years I've used C/C++/C#, used the braces on a line of its own, unindented. -- LuisR ___________ Luis Alonso Ramos Chihuahua, Mexico www.luisalonsoramos.com
-
private:
void foo()
{
//statements
}Company standard. Felt strange at first, but I got used to it, and now I use it everywhere
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
Sorry, but this is anal. X|
-
i've been chatting with the new guy at work today and he respectfully informs me he can't recall the last time he saw this notation: private void foo() { //statements } and contends that almost always people use: private void foo() { //statements } which to me is a total waste of a linebreak and less readable. worse still, the other new dude concurs? whassup with that? being a fan of the former notation, it seems to me that either the new generation of coders are being being taught different, or the old ones are getting too anal about space. my question is... what in fact is the standard? perhaps we should have a poll on CodeProject and settle this once and for all!
In my mind, both are valid!:omg:
void foo() {
if (!false) {
burp();
}
}or
void foo(
int param1, // doc param 1
int param2, // doc param 2
int param3
)
{
burp();
}Why? I do not like CLOSING parentheses or braces lost on the end of broken/multi lines. Opening braces should be placed at the most logical point. You see, too many blanks/dim lines are just as detrimental as cramming.
-
private:
void foo()
{
//statements
}Company standard. Felt strange at first, but I got used to it, and now I use it everywhere
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
Eeeuw. Anyone who finds this to be clear simply has difficulty thinking straight.
-
*must* *resist* *to* *flame* *Jörgen*
we are here to help each other get through this thing, whatever it is Vonnegut jr.
sighist || Agile Programming | doxygenBring it on! I've got skin made of asbest. ;) -- Denn du bist, was du isst! Und ihr wisst, was es ist! Es ist mein Teil...?
-
i've been chatting with the new guy at work today and he respectfully informs me he can't recall the last time he saw this notation: private void foo() { //statements } and contends that almost always people use: private void foo() { //statements } which to me is a total waste of a linebreak and less readable. worse still, the other new dude concurs? whassup with that? being a fan of the former notation, it seems to me that either the new generation of coders are being being taught different, or the old ones are getting too anal about space. my question is... what in fact is the standard? perhaps we should have a poll on CodeProject and settle this once and for all!
Version 2 is of course the only correct version. :) And I've worked in a lot of enterprise environments where I've never seen anything but v2 there.
-
i've been chatting with the new guy at work today and he respectfully informs me he can't recall the last time he saw this notation: private void foo() { //statements } and contends that almost always people use: private void foo() { //statements } which to me is a total waste of a linebreak and less readable. worse still, the other new dude concurs? whassup with that? being a fan of the former notation, it seems to me that either the new generation of coders are being being taught different, or the old ones are getting too anal about space. my question is... what in fact is the standard? perhaps we should have a poll on CodeProject and settle this once and for all!
I tend to use the 2nd format, but I wouldn't roll over and play dead if I saw the first. Imho, they're both readable and not worth getting into a religious discussion over. However, if you're talking about ham and Wonder bread or Maxwell House instant coffee (made with tap water and a microwave), I have some REALLY strong opinions. /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com
-
i've been chatting with the new guy at work today and he respectfully informs me he can't recall the last time he saw this notation: private void foo() { //statements } and contends that almost always people use: private void foo() { //statements } which to me is a total waste of a linebreak and less readable. worse still, the other new dude concurs? whassup with that? being a fan of the former notation, it seems to me that either the new generation of coders are being being taught different, or the old ones are getting too anal about space. my question is... what in fact is the standard? perhaps we should have a poll on CodeProject and settle this once and for all!
How do you line up the braces using the first notation? I occasionally (not too often) have nested levels where the second notation really helps me figure out where I am. With the first notation, how do you make sure all your braces match, and that they match in the places? (uh, yeah, I guess there's the IDE thingy that shows code blocks, but I actually don't really use that). Marc Microsoft MVP, Visual C# MyXaml MyXaml Blog Hunt The Wumpus RealDevs.Net
-
Bring it on! I've got skin made of asbest. ;) -- Denn du bist, was du isst! Und ihr wisst, was es ist! Es ist mein Teil...?
-
How do you line up the braces using the first notation? I occasionally (not too often) have nested levels where the second notation really helps me figure out where I am. With the first notation, how do you make sure all your braces match, and that they match in the places? (uh, yeah, I guess there's the IDE thingy that shows code blocks, but I actually don't really use that). Marc Microsoft MVP, Visual C# MyXaml MyXaml Blog Hunt The Wumpus RealDevs.Net
I just line up the
if
,for
,whatever
with the ending}
. I used to be a v2 kind of guy, but for some reason I switched over (except for non-inline functions). It seems I'm the only one where I work. :) -- Denn du bist, was du isst! Und ihr wisst, was es ist! Es ist mein Teil...? -
private:
void foo()
{
//statements
}Company standard. Felt strange at first, but I got used to it, and now I use it everywhere
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
-
i've been chatting with the new guy at work today and he respectfully informs me he can't recall the last time he saw this notation: private void foo() { //statements } and contends that almost always people use: private void foo() { //statements } which to me is a total waste of a linebreak and less readable. worse still, the other new dude concurs? whassup with that? being a fan of the former notation, it seems to me that either the new generation of coders are being being taught different, or the old ones are getting too anal about space. my question is... what in fact is the standard? perhaps we should have a poll on CodeProject and settle this once and for all!
The first style is the ansi c standard and was invented at a time when we where all using 80 * 24 screens to code with ie saving lines onscreen was important. The second style is IMHO the more natural, intuitive, readable etc etc and whilst I can cope with both. The second style is all i have used for the last 15 ~ 20 years (unless forced at gun point by some anal coding standards nazi ;))