- Joined
- Aug 18, 2002
- Location
- New Jersey
I've got some questions as to what habits you would generally consider "bad".
1)One common thing is bracket (or braces) placement.
while(x==5){
or
while (x==5) //Included a space here, too.
{
I like the first one since having a whole space for the bracket seems too, i dunno, space consuming.
2)Documentation. How often do you do it? I dont really like it since i know exactly what my program is, but i guess it would be more helpful for my teacher. But I would only document if i'm showing the program to someone who doesnt catch the drift of a program quickly.
3)Naming variables. I always use the shortest variable name possible. No underscore or capitalization. Takes too long to press shift and the underscore key. Sometimes i just use a,b,c,d as variable names for counters. But now, im using a,b,c,d less and less. =]
4)LOOOONG parameters. For one function i had like 8 parameters. It was the only way i could find that maybe the program most efficient. =[
5)Break and continue. I use break, a lot. Not too much with continue though.
6)Switch. It doesnt work for most cases so i just use a bunch of if's. Switch is pretty elegant though.
7)Just thought of this: If you have an if that doesnt require brackets (one line) then i guess you can write it like this:
if(x==5) y=3;
Anyone else who knows any "bad habits" and would like to add them to discuss can do surely add them. What are your opininons on the ones i listed? I dont think theyre that bad.
Btw, do colleges reject your work if its not their programming style?
1)One common thing is bracket (or braces) placement.
while(x==5){
or
while (x==5) //Included a space here, too.
{
I like the first one since having a whole space for the bracket seems too, i dunno, space consuming.
2)Documentation. How often do you do it? I dont really like it since i know exactly what my program is, but i guess it would be more helpful for my teacher. But I would only document if i'm showing the program to someone who doesnt catch the drift of a program quickly.
3)Naming variables. I always use the shortest variable name possible. No underscore or capitalization. Takes too long to press shift and the underscore key. Sometimes i just use a,b,c,d as variable names for counters. But now, im using a,b,c,d less and less. =]
4)LOOOONG parameters. For one function i had like 8 parameters. It was the only way i could find that maybe the program most efficient. =[
5)Break and continue. I use break, a lot. Not too much with continue though.
6)Switch. It doesnt work for most cases so i just use a bunch of if's. Switch is pretty elegant though.
7)Just thought of this: If you have an if that doesnt require brackets (one line) then i guess you can write it like this:
if(x==5) y=3;
Anyone else who knows any "bad habits" and would like to add them to discuss can do surely add them. What are your opininons on the ones i listed? I dont think theyre that bad.
Btw, do colleges reject your work if its not their programming style?