Quote:
Originally Posted by btslaser
Thanks for this cookbook... it has helped us tremendously.
One question... in the example Command described, you get various subsystems using [Subsystem].getInstance(). In the Subsystem class there is not a static instance member, rather it is in the CommandBase. Do you recommend putting the static instance in the CommandBase or putting it in the Subsystem and writing a GetInstance() method on the Subsystem? Sample below.
public class DriveWithJoystick extends CommandBase {
Chassis m_chassis;
public DriveWithJoystick() {
m_chassis = Chassis.getInstance(); // not available...
requires(m_chassis); // reserve the chassis subsystem
}
|
We thought that it was easier to use the CommandBase class. What happened was that I did a presentation on the command based programming style and found myself spending 10 minutes explaining about singletons and static variables. And the code looked much cleaner if you just can reference the subsystem class instances with a simple variable. So either works, but we thought it was cleaner to not use all the static variables - and the subsystems themselves, often only a few lines of non-boilerplate code, got much smaller.
Brad