View Single Post
  #6   Spotlight this post!  
Unread 24-06-2002, 00:53
archiver archiver is offline
Forum Archival System
#0047 (ChiefDelphi)
 
Join Date: May 2001
Location: Pontiac, MI
Posts: 21,214
archiver has a reputation beyond reputearchiver has a reputation beyond reputearchiver has a reputation beyond reputearchiver has a reputation beyond reputearchiver has a reputation beyond reputearchiver has a reputation beyond reputearchiver has a reputation beyond reputearchiver has a reputation beyond reputearchiver has a reputation beyond reputearchiver has a reputation beyond reputearchiver has a reputation beyond repute
Something to be said for readable code...

Posted by Nate Smith at 2/15/2001 12:02 PM EST


Other on team #66, Frostbite, from Willow Run High School and GM Powertrain.


In Reply to: Re: EVEN MORE PBASIC HELP, ASAP!!
Posted by Stephen on 2/14/2001 10:15 PM EST:



: I recomend you not make PWM1(or any PWM) a variable. It just, simply put, wastes those 26 variables. Just go to the serout command, and where PWM1 is, just put p1_y. This also works for other things, I'll give you one more example. We have a servo, that will be 156 when nothing is pressed (closed position), and 10 when p1_sw_top is pressed (open position), instead of wasting a variable and putting an again wasteful if loop in, I just went to the serout command, and at PWM4 wrote
: ((p1_sw_top ^ 1)*146)+10

While I agree that in some cases, it is easiest to just put the variable(in the case of PWM1 = p1_y) or maybe a SHORT formula directly in the serout command, I've also seen some code in my workings with the Innovation First controller that takes several lines to accomplish(i.e. smooth the joystick input, implement a dead zone, etc., etc...) that would be a NIGHTMARE to try and code all into the serout. And even if it can be shortened enough to warrant putting it in the serout, which is easier to quickly understand(i.e. making a quick fix between matches)?

- PWM4 = ((p1_sw_top ^ 1) * 148)+10

OR
- serout USERCPU,OUTBAUD, [255,255,p1_y,relayA,p2_y,p3_y,((p1_sw_top ^ 1) * 148)+10,p4_y,p1_x,p2_x,p3_x,p4_x,p1_wheel,p2_wheel ,p3_wheel,p4_wheel,127,127,127,127]

As a 3rd semester CS major, I have very quickly learned the importance of easy-to-understand code, even if it results in a slightly larger or smaller program.

Just my thoughts...

Nate

__________________
This message was archived from an earlier forum system. Some information may have been left out. Start new discussion in the current forums, and refer back to these threads when necessary.