|
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.
|