Until now, all the team projects I've worked on had no coding conventions whatsoever, whether at school or at my internship. Now, when I was at my internship, I tried to stick with the de facto conventions present in the code, but there are times where I'd do my way instead.
For instance, I think in a C-based language, if-else statements should be written like so:
if (condition) {
statements
}
else {
statements
}
instead of the more traditional
if (condition) {
statements
} else {
statements
}
And that one-line if-statements are unacceptable. I've too often seen this:
if (condition)
statement 1
statement 2
statement 3
Where indentation suggests statement 2 is conditional, when it's not. This is incredibly misleading, and yes, I've seen it cause bugs. So I always refactor that code as:
if (condition) {
statement 1
}
statement 2
statement 3
I also think predicates should be named isSomething(), and other such conventions.
Now, I tend to take it pretty personal when someone in the team changes function names, layout etc in my code, without discussing it with me first. However, even if we discuss it, there's no easy way to reach common ground on these matters. For instance, my school teachers think all methods should be preceded by such monstrosities:
/*************************************************
* function name : add *
* arguments : *
* int number1 : the first number to add *
* int number2 : the second number to add *
* returns : the sum of number1 and number2 *
* author : Dr_Asik *
* last modified : 6/01/09 *
* author's blood group : AB+ *
* more crap *
* even more crap *
* *
*************************************************/
int add(int number1, int number2) {
return number1 + number2;
}
...which are such a pure GIMMICK and an utter WASTE OF TIME, it makes me wanna hit someone.
How do you cope with projects where there are no established conventions? Above all else I think maintaining good, open relations with my team members is the most important, so I'm a bit embarassed when it comes to coding conventions. Either we adopt mine or someone else's, and it becomes a matter of who's able to prove his authority over the team better. I don't like it, especially if we're equal team members on the project.
Question
Andre S. Veteran
Until now, all the team projects I've worked on had no coding conventions whatsoever, whether at school or at my internship. Now, when I was at my internship, I tried to stick with the de facto conventions present in the code, but there are times where I'd do my way instead.
For instance, I think in a C-based language, if-else statements should be written like so:
if (condition) { statements } else { statements }instead of the more traditional
if (condition) { statements } else { statements }And that one-line if-statements are unacceptable. I've too often seen this:
Where indentation suggests statement 2 is conditional, when it's not. This is incredibly misleading, and yes, I've seen it cause bugs. So I always refactor that code as:
if (condition) { statement 1 } statement 2 statement 3I also think predicates should be named isSomething(), and other such conventions.
Now, I tend to take it pretty personal when someone in the team changes function names, layout etc in my code, without discussing it with me first. However, even if we discuss it, there's no easy way to reach common ground on these matters. For instance, my school teachers think all methods should be preceded by such monstrosities:
/************************************************* * function name : add * * arguments : * * int number1 : the first number to add * * int number2 : the second number to add * * returns : the sum of number1 and number2 * * author : Dr_Asik * * last modified : 6/01/09 * * author's blood group : AB+ * * more crap * * even more crap * * * *************************************************/ int add(int number1, int number2) { return number1 + number2; }...which are such a pure GIMMICK and an utter WASTE OF TIME, it makes me wanna hit someone.
How do you cope with projects where there are no established conventions? Above all else I think maintaining good, open relations with my team members is the most important, so I'm a bit embarassed when it comes to coding conventions. Either we adopt mine or someone else's, and it becomes a matter of who's able to prove his authority over the team better. I don't like it, especially if we're equal team members on the project.
Edited by Dr_AsikLink to comment
Share on other sites
35 answers to this question
Recommended Posts