Conditions | 1 |
Total Lines | 51 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | package org.usfirst.frc.team3695.robot; |
||
21 | public OI() { |
||
|
|||
22 | /// manipulator wheels |
||
23 | Button spinIn = new JoystickButton(OPERATOR, Xbox.RB); |
||
24 | spinIn.whileHeld(new ButtonCommandEat()); |
||
25 | Button spinOut = new JoystickButton(OPERATOR, Xbox.LB); |
||
26 | spinOut.whileHeld(new ButtonCommandSpit()); |
||
27 | /// manipulator clamp |
||
28 | Button toggleClamp = new JoystickButton(OPERATOR, Xbox.A); |
||
29 | toggleClamp.toggleWhenActive(new ToggleCommandClamp()); |
||
30 | /// candy cane |
||
31 | Button toggleHook = new JoystickButton(OPERATOR, Xbox.B); |
||
32 | toggleHook.toggleWhenActive(new ToggleCommandHook()); |
||
33 | /// drop the mast |
||
34 | Button dropIt = new JoystickButton(OPERATOR, Xbox.X); |
||
35 | dropIt.toggleWhenPressed(new ButtonCommandHitTheDeck()); |
||
36 | /// Reversing mode |
||
37 | Button toggleReverse = new JoystickButton(DRIVER, Xbox.Y); |
||
38 | toggleReverse.toggleWhenPressed(new ToggleCommandReverse()); |
||
39 | /// Docking mode |
||
40 | Button toggleDock = new JoystickButton(DRIVER, Xbox.X); |
||
41 | toggleDock.toggleWhenPressed(new ToggleCommandDock()); |
||
42 | /// To Compress, or Not To Compress. It is now an option. |
||
43 | SmartDashboard.putData("Disable Compressor", new ToggleCommandKillCompressor()); |
||
44 | |||
45 | |||
46 | /// PID |
||
47 | SmartDashboard.putData("Kill PID", new ToggleCommandKillPID()); |
||
48 | SmartDashboard.putNumber("Right Encoder Position", 0); |
||
49 | SmartDashboard.putNumber("Left Encoder Position", 0); |
||
50 | |||
51 | /// limit switch displays |
||
52 | SmartDashboard.putBoolean("Lower Screw", true); |
||
53 | SmartDashboard.putBoolean("Upper Screw", false); |
||
54 | SmartDashboard.putBoolean("Lower Pinion", true); |
||
55 | SmartDashboard.putBoolean("Upper Pinion", false); |
||
56 | |||
57 | SmartDashboard.putNumber("Left inches", 0); |
||
58 | SmartDashboard.putNumber("Right inches", 0); |
||
59 | |||
60 | DriverStation.reportWarning("OI IS INSTANTIATED", false); |
||
61 | |||
62 | /// Cyborg command testers |
||
63 | SmartDashboard.putData("Drive Direct", new CyborgCommandDriveDirect(Util.getAndSetDouble("Drive Direct Power", 0))); |
||
64 | SmartDashboard.putData("Drive Distance", new CyborgCommandDriveDistance(Util.getAndSetDouble("Drive Distance Inches", 0))); |
||
65 | SmartDashboard.putData("Drive Until Error", new CyborgCommandDriveUntilError()); |
||
66 | SmartDashboard.putData("Rotate Degree", new CyborgCommandRotateDegrees(Util.getAndSetDouble("Rotate Degrees", 0))); |
||
67 | SmartDashboard.putData("Spit", new CyborgCommandSpit((long)Util.getAndSetDouble("Spit Time", 500))); |
||
68 | SmartDashboard.putData("Raise to Position: Pinion Up", new CyborgCommandGrow(Mast.PINION_UP)); |
||
69 | SmartDashboard.putData("Raise to Position: Pinion Down", new CyborgCommandGrow(Mast.PINION_DOWN)); |
||
70 | SmartDashboard.putData("Raise to Position: Screw Up", new CyborgCommandGrow(Mast.SCREW_UP)); |
||
71 | SmartDashboard.putData("Raise to Position: Screw Down", new CyborgCommandGrow(Mast.SCREW_DOWN)); |
||
72 | } |
||
74 | } |