Go to Post It is great to see your friends and other teams succeed. - Bob Steele [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
View Poll Results: Who uses white space?
Yes, i make it so people can read my code 39 69.64%
Yes, i make it so i think that others can resd it 7 12.50%
No, only I can read my code 3 5.36%
I think that only i can read my code 3 5.36%
I don't understand the question. 4 7.14%
Voters: 56. You may not vote on this poll

Closed Thread
Thread Tools Rate Thread Display Modes
  #16   Spotlight this post!  
Unread 18-03-2009, 16:01
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: "White space"

Quote:
Originally Posted by basicxman View Post
Extra code doesn't add any weight.
Right. It's the other way around. The erased state of flash memory is a logic one, so adding code actually removes bits.
  #17   Spotlight this post!  
Unread 18-03-2009, 16:04
EricVanWyk EricVanWyk is offline
Registered User
no team
 
Join Date: Jan 2007
Rookie Year: 2000
Location: Boston
Posts: 1,597
EricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond repute
Send a message via AIM to EricVanWyk
Re: "White space"

Quote:
Originally Posted by Alan Anderson View Post
Right. It's the other way around. The erased state of flash memory is a logic one, so adding code actually removes bits.
Bah, the weight savings of a few electrons in flash are nothing. We added a few vandegraph generators to the bot to remove some real electrons!
  #18   Spotlight this post!  
Unread 18-03-2009, 16:25
billbo911's Avatar
billbo911 billbo911 is offline
I prefer you give a perfect effort.
AKA: That's "Mr. Bill"
FRC #2073 (EagleForce)
Team Role: Mentor
 
Join Date: Mar 2005
Rookie Year: 2005
Location: Elk Grove, Ca.
Posts: 2,355
billbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond repute
Re: "White space"

Quote:
Originally Posted by EricVanWyk View Post
We added a few vandegraph generators to the bot to remove some real electrons!
And you wonder why we are getting static charge build up this year.

__________________
CalGames 2009 Autonomous Champion Award winner
Sacramento 2010 Creativity in Design winner, Sacramento 2010 Quarter finalist
2011 Sacramento Finalist, 2011 Madtown Engineering Inspiration Award.
2012 Sacramento Semi-Finals, 2012 Sacramento Innovation in Control Award, 2012 SVR Judges Award.
2012 CalGames Autonomous Challenge Award winner ($$$).
2014 2X Rockwell Automation: Innovation in Control Award (CVR and SAC). Curie Division Gracious Professionalism Award.
2014 Capital City Classic Winner AND Runner Up. Madtown Throwdown: Runner up.
2015 Innovation in Control Award, Sacramento.
2016 Chezy Champs Finalist, 2016 MTTD Finalist
  #19   Spotlight this post!  
Unread 18-03-2009, 17:13
Lord_Jeremy's Avatar
Lord_Jeremy Lord_Jeremy is offline
Lord_Jeremy the Procrastinator
AKA: Jeremy Agostino
FRC #1546 (Chaos Inc.)
Team Role: Electrical
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Baldwin, New York
Posts: 45
Lord_Jeremy is an unknown quantity at this point
Send a message via ICQ to Lord_Jeremy Send a message via AIM to Lord_Jeremy Send a message via MSN to Lord_Jeremy Send a message via Yahoo to Lord_Jeremy
Re: "White space"

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!
__________________
Compiling...
Compiling...
  #20   Spotlight this post!  
Unread 18-03-2009, 19:46
writchie writchie is offline
Engineering Mentor
AKA: Wally Ritchie
FRC #2152 (Team Daytona)
Team Role: Coach
 
Join Date: Dec 2007
Rookie Year: 2007
Location: Daytona Beach, Florida
Posts: 148
writchie has a reputation beyond reputewritchie has a reputation beyond reputewritchie has a reputation beyond reputewritchie has a reputation beyond reputewritchie has a reputation beyond reputewritchie has a reputation beyond reputewritchie has a reputation beyond reputewritchie has a reputation beyond reputewritchie has a reputation beyond reputewritchie has a reputation beyond reputewritchie has a reputation beyond repute
Re: "White space"

Quote:
Originally Posted by Alan Anderson View Post
Right. It's the other way around. The erased state of flash memory is a logic one, so adding code actually removes bits.
Ahhh, but the process of writing a "zero" is done by injecting electrons into the float gate. So a programmed device has the mass of these electrons (which is of course negligible).
  #21   Spotlight this post!  
Unread 18-03-2009, 21:22
dooey100 dooey100 is offline
Registered User
FTC #3037
 
Join Date: Feb 2009
Location: Fernie
Posts: 47
dooey100 is on a distinguished road
Re: "White space"

You are missing an option on that poll:

"I can't even read my own code"
  #22   Spotlight this post!  
Unread 19-03-2009, 00:18
basicxman basicxman is offline
Emily Horsman
FRC #2200 (MMRambotics)
Team Role: Programmer
 
Join Date: Oct 2007
Rookie Year: 2007
Location: Burlington, Ontario
Posts: 971
basicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant future
Send a message via AIM to basicxman Send a message via MSN to basicxman Send a message via Yahoo to basicxman
Re: "White space"

Sorry I didn't specify, adding or removing code does not change the weight!!

Anyways, here's some sample code from my joystick for FTC, this is how I like things whitespaced

Code:
while (true) { //whitespace after an important conditional or loop

  getJoystickSettings(joystick); //single linebreak for basic commands and function calling
  setMotors("default"); //double linebreak when another main conditional is about to appear

  if (joystick.joy1_y1 > 40 || joystick.joy1_y1 < -40) { //single linebreak for a final conditional in nests
    motor[motorD] = joystick.joy1_y1; 
  }

}
  #23   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

  #24   Spotlight this post!  
Unread 19-03-2009, 15:48
Lord_Jeremy's Avatar
Lord_Jeremy Lord_Jeremy is offline
Lord_Jeremy the Procrastinator
AKA: Jeremy Agostino
FRC #1546 (Chaos Inc.)
Team Role: Electrical
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Baldwin, New York
Posts: 45
Lord_Jeremy is an unknown quantity at this point
Send a message via ICQ to Lord_Jeremy Send a message via AIM to Lord_Jeremy Send a message via MSN to Lord_Jeremy Send a message via Yahoo to Lord_Jeremy
Re: "White space"

Quote:
Originally Posted by EricH View Post
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.
I usually only space out the parameter list when there's a large number of parameters. In the example I tried to show that there were 20 parameters
__________________
Compiling...
Compiling...
  #25   Spotlight this post!  
Unread 19-03-2009, 15:50
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 usually only space out the parameter list when there's a large number of parameters. In the example I tried to show that there were 20 parameters
What I prefer to do is to put a parameter list in the header comment. No extra comments... and the list is right behind it.

Then again, you should see some of my if statements and the conditions in them...
__________________
Past teams:
2003-2007: FRC0330 BeachBots
2008: FRC1135 Shmoebotics
2012: FRC4046 Schroedinger's Dragons

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

  #26   Spotlight this post!  
Unread 19-03-2009, 16:20
Andrew Schreiber Andrew Schreiber is offline
Joining the 900 Meme Team
FRC #0079
 
Join Date: Jan 2005
Rookie Year: 2000
Location: Misplaced Michigander
Posts: 4,059
Andrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond repute
Re: "White space"

I would like to bring up the topic of the ternary operator. For those of you who do not know, in C you can use a?b:c; and have it as a completely valid statement so for example:
Code:
int foo(int bar)
{
  return bar>0?1:-1;
}
The above is valid code and will return -1 if bar is negative and 1 otherwise. This is pretty clean code and, assuming you know the operator, is easy to read. Just curious what people think about it since we are talking about making code easier. I know that most of my college professors, though knowing the operator, do not like me using it.
__________________




.
  #27   Spotlight this post!  
Unread 19-03-2009, 17:22
nathanww nathanww is offline
Hacker
FRC #1678 (Citrus Circuits)
Team Role: Programmer
 
Join Date: Dec 2008
Rookie Year: 2007
Location: Davis, CA
Posts: 224
nathanww is just really nicenathanww is just really nicenathanww is just really nicenathanww is just really nice
Re: "White space"

ternary operator=blech. The problem with it is even if you know what it does(which not everyone does), I prefer syntax that actually reflects the logic of the process(like a standard if/else)

As for whitespace--I am known among some people for writing "MLA code"--basically, I code the same way that I would right an essay, with indents, paragraphs, etc.
__________________
Get yer robot source code here!
  #28   Spotlight this post!  
Unread 29-03-2009, 17:02
kyungjin kyungjin is offline
Software Specialist
AKA: Daniel
VRC #0646
Team Role: Programmer
 
Join Date: Aug 2008
Rookie Year: 2009
Location: Honolulu, Hawaii
Posts: 65
kyungjin is an unknown quantity at this point
Send a message via AIM to kyungjin Send a message via MSN to kyungjin
Re: "White space"

Quote:
Originally Posted by virtuald View Post
Why wouldn't you use white space?
Ditto that. Was wondering why there wasn't a poll option for that...
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Championship Event - Where the "Random" Match Sorting Really "Shines" Travis Hoffman Championship Event 57 19-04-2007 08:06
New NEMO White Papers! "Creating a Killer Packet" and "25 Ways to Sponsor" Jessica Boucher Team Organization 0 10-08-2005 10:55
Team 1126 "Crazy Wheels" white paper Alex Cormier Technical Discussion 1 25-10-2004 15:54
"Thunderbirds" Vs. "Team America" Which one will rule the box office? Elgin Clock Chit-Chat 3 07-09-2004 19:53
Transcript: "The Space Shuttle Columbia Accident: What's Next?" DanL General Forum 2 03-03-2003 21:35


All times are GMT -5. The time now is 02:25.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi