Popular coding style?

Started by
53 comments, last by GameDev.net 17 years, 8 months ago
Second all the way! I usually convert all code to it if it's something else.

One more thing, I didn't saw here.

Imagine C -

void foo(){int i, j;somefunc();/*and more code here 5-10 lines, maybe 50...*///use i and j herei=foo1();j=i%foo2();somemorefunc();{int i;someotherfunc(i)}


Tell me what you want but this looks fugly... And you do use braces to alter scopes and declare local variables in lenghty C;

Oups, just noticed... What's wrong with that code? - Additional } missing in the end.

So to each it's own...
______________________________Madman
Advertisement
Quote:Original post by JasonBlochowiak
Mouse? While editing source? That's scary inefficient.


Really? click-backspace-click doesn't seem so slow to me to move blocks of code around.

Quote:
Quote:
And, like most micro-optimizations, this sort of thing doesn't really enter into my considerations. I spend more time thinking about the code than moving it around or even writing it.


Micro optimizations are appropriate for highly used operations - same for process, same for code.


My point was that, in my experience, this isn't a highly used operation. I spend more time thinking and planning out my code and algorithms than I do actually typing or wiggling the mouse. Then again, maybe my requirements are different. Most of my work is scientific computing. Considering the state of many programs, it wouldn't surprise me if you software developers didn't think at all. (I kid! I kid! [smile])


Quote:Original post by _Madman_
Tell me what you want but this looks fugly... And you do use braces to alter scopes and declare local variables in lenghty C;

Oups, just noticed... What's wrong with that code? - Additional } missing in the end.


I've never seen anyone seriously program without indenting.

Anyway, that error's easy to spot. The autoindent will be messed up by the missing }, so I'll just have emacs show me which } matches which {. Actually, I noticed it even more quickly due to the absurd { after a function call.

As for using scopes like that, it does happen, but rarely. Most of the time one separates that bit out into another function.
I generally use the second style when working on own projects. When working on other projects, I use the style recommended for that project, which has lately been mostly the first style.
function(this){    if(that){        do some stuff;    }    else{        do this other stuff;    }}


always been my coding style. I was never taught by anybody to do any style. It just developed on its own into that since its easy for me to read and edit.
this and that are just placeholders for what would normally go in those parentheses.
I like to use the first (K&R) style on really short or inlined function/method definitions, and the second (BSD) style everywhere else.

This topic is closed to new replies.

Advertisement