Version 1 (modified by 10 years ago) (diff) | ,
---|
Design Patterns (in Java)
Overarching Structural Patterns
Command-Based FRC Robot (Event-Based)
Please see the Command Based Robot Notes for detailed information on how to implement this design pattern.
MVC (Model-View-Controller)
This pattern is concerned with the separation and cohesion of different "departments" of a project.
The model is the data required by the project. The view is the client interface, often a gui (although with respect to a robot, this is more analogous to the actuators and code representations of the mechanisms). The controller is the collection of classes that process and handle the data and make logical decisions.
Generally, these three major divisions of code are separated, both physically (as physical as 0's and 1's can get) and in the interfaces between the three:
- The model should be protected from arbitrary access and should only be accessed through the controller.
- The view should generally query for information updates from either the model or the controller.
- The controller should receive information updates from the model and control the view.
Iterative Control Loop
This is the simplest pattern; it involves a set of instructions/commands being repeated over and over again until a termination command is given.
This entails that inside the loop, there cannot be anything that requires a large amount of processing power or time. Each instruction should be relatively short and not take up not. There should be no while loops, or lengthy for loops.