think tank forum

technology » coding style

asemisldkfj's avatar
15 years ago
link
asemisldkfj
the law is no protection
what does your code look like? format this if statement! (taken from the Wikipedia page on programming style)

if (hours < 24 && minutes < 60 && seconds < 60) {
    return true;
}
else {
    return false;
}


I think I made up my own indent style. that "else" should probably go on the same line as the first closing brace.
andre's avatar
15 years ago
link
andre
I prefer "} else {" but I'd write that code as

return (hours < 24 && minutes < 60 && seconds < 60)
:P
bluet's avatar
15 years ago
link
bluet
return (hours < 24 && minutes < 60 && seconds < 60);
:)
lucas's avatar
15 years ago
r1, link
lucas
i ❤ demo
if (hours < 24 && minutes < 60 && seconds < 60) {

    return true;

} else {

    return false;

};


if the variable names were longer, i'd do this:

if (hours   < 24 &&
    minutes < 60 &&
    seconds < 60) {

    return true;

} else {

    return false;

};
Weasley's avatar
15 years ago
r1, link
Weasley
20 x 10 living
if (hours < 24 && minutes < 60 && seconds < 60)
{
     return true;
}
else
{
     return false;
}


Anything in a bracket is tabbed.
Weasley's avatar
15 years ago
link
Weasley
20 x 10 living
http://cloudcms.googlecode.com/svn/trunk/index.php this sums up my coding style.

I prefer ' than "
bluet's avatar
15 years ago
link
bluet
I prefer ", it's easier to type on a Norwegian keyboard.
 
15 years ago
link
arun
keep smiling !
I use " only when there's a need for interpolation.
lucas's avatar
15 years ago
link
lucas
i ❤ demo
i try to do the same as arun--i'd guess that single-quotes are marginally faster.
bluet's avatar
15 years ago
link
bluet
> i try to do the same as arun--i'd guess that single-quotes are marginally faster.

If you're using a language where there's a difference in meaning, it's not really a question of coding style. I use Python a lot, where " means exactly the same as '.
DaGr8Gatzby's avatar
15 years ago
link
DaGr8Gatzby
Drunk by Myself
I agree with Weasley