View Single Post
  #5   Spotlight this post!  
Unread 30-04-2013, 03:16
Hjelstrom's Avatar
Hjelstrom Hjelstrom is offline
Mentor
FRC #0987 (High Rollers)
Team Role: Mentor
 
Join Date: Mar 2008
Rookie Year: 2005
Location: Las Vegas
Posts: 147
Hjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond repute
Re: Reducing code complexity

I really don't recommend using the ? or ^ operators just to make your code smaller. It will just make the code harder to read and understand which is far more important than how big it is. The switch statement is a good idea though.

Instead, how about moving all of the code related to the shooter into a function and all of the code related to the drivetrain into another one, etc.

What we do is take the idea a little farther and use a separate class for each subsystem and that class even contains the speed controller objects, the sensors, etc. Within our classes though, there are plain old 'if' statements.