Thread: "White space"
View Single Post
  #2   Spotlight this post!  
Unread 19-03-2009, 01:01
EricH's Avatar
EricH EricH is offline
New year, new team
FRC #1197 (Torbots)
Team Role: Engineer
 
Join Date: Jan 2005
Rookie Year: 2003
Location: SoCal
Posts: 19,774
EricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond repute
Re: "White space"

Quote:
Originally Posted by Lord_Jeremy View Post
I love white space. I do stuff like this:
Code:
function(
        int     parameter 1 , //comment
        int     parameter 2 , //comment
...
        word    parameter20 ) //more comment
Unfortunately the other programmers would do stuff like:
Code:
function(int parameter1,int parameter2, ... word parameter20)
All on one line. And when I space it out they complain! It's horrible!
It actually makes more sense (to me) to have it on one line with a few spaces in between. Ideally, you've chosen descriptive variable names, so comments are not totally necessary.

Now, if a line is getting too long, I will break it between parameters to for readability.

And no, I haven't had anyone complain about not enough whitespace yet. The parameters for my C++ class last semester were something like 1 extra line between groups of lines (say, between 2 for loops) and 3 lines between functions, plus the comment lines. I think I had about 650+ lines for a "voting machine" program, including whitespace and comment after comment after comment--and throw in some code for good measure.

Actually, one quote I've seen on here in the spotlights is: "A programmer's job is to write documentation that just happens to compile.", or something like that. Because it's documentation, it needs to be readable. I'd have a hard time reading the code above, due to the fact that having all the parameters separate from the header makes them look like variable declarations within the function. That's probably why they're complaining--they can't tell whether or not you're declaring variables or parameters. If you do do it this way, you might want to indicate in the comment that it's a parameter before anything else.
__________________
Past teams:
2003-2007: FRC0330 BeachBots
2008: FRC1135 Shmoebotics
2012: FRC4046 Schroedinger's Dragons

"Rockets are tricky..."--Elon Musk