Code that works is not the same thing as good code. A lot of rookie teams write everything inside the same file and suffer for it weeks later, when they need to change something small and no longer know where to touch it.
Why organize?Link to this section
Putting everything inside the OpMode (the main class that runs the robot) seems simpler at first, but it quickly turns into a giant, hard-to-understand file. Separating responsibilities makes testing and maintenance easier, and especially helps teamwork — several people can work on different parts of the code without stepping on each other's toes.
- Understand why putting everything inside the OpMode makes the code hard to maintain.
- Learn to separate responsibilities.
- Make testing, maintenance and teamwork easier.
SubsystemsLink to this section
The most common practice in FTC is to use one class to represent each physical subsystem of the robot — drivetrain, intake, lift, for example. Each of these classes talks to the main OpMode, but handles its own logic internally.
- Use one class to represent each robot subsystem.
- Separate, for example, drivetrain, intake and lift.
- Understand how these classes talk to the OpMode.
Folder structureLink to this section
Organizing files into folders — separating commands, subsystems and utilities — creates a structure that can grow along with the robot's complexity throughout the season, instead of turning into a mess of loose files.
- Organize files so they're easy to find.
- Separate commands, subsystems and utilities when it makes sense.
- Build a structure that can grow along with the robot.