RobotController (RC) has grown to gigantic proportions and dealing with tens of different things.
It was accepted at the beginning that :
RC would "know" about (almost) everything
RC being the "brain" of the robot, its goal was to link things together to bring Leka to life.
RC would break the Single Responsibility Principle
With new states, events, callbacks, behaviors, actuators, added almost everyday, it's getting harder and harder to keep RC well organized, the entities well named and the logic cristal clear.
In particular, unit tests are very thorough but are very hard to read, very hard to understand and very hard to change if the specifications were to evolve.
Solution
The proposed solution is to divide the current RobotController in different modules with limited responsibilities:
state machine - defines all the states, events, actions, transitions of the system
scheduler - defines the different timers, timeouts, durations of the system
events - defines (hardware) events of the system (BLE connection/disconnection, charging, etc.) and raise them
states/guards
actions/callbacks
behaviors (?)
DI and virtual interfaces can be used for easier unit testing.
This division will also allow us to really do siloed unit tests and to better specify the behaviors.
Steps
[ ] rename sm::action::start_<event>_behavior to sm::action::on_<event>
[ ] create RobotScheduler module
[ ] create RobotEvents module
[ ] create RobotStates module
[ ] clean up RobotController to keep only the actions/callbacks
Diviser pour mieux régner
Context
RobotController
(RC) has grown to gigantic proportions and dealing with tens of different things.It was accepted at the beginning that :
With new states, events, callbacks, behaviors, actuators, added almost everyday, it's getting harder and harder to keep RC well organized, the entities well named and the logic cristal clear.
In particular, unit tests are very thorough but are very hard to read, very hard to understand and very hard to change if the specifications were to evolve.
Solution
The proposed solution is to divide the current
RobotController
in different modules with limited responsibilities:DI and virtual interfaces can be used for easier unit testing.
This division will also allow us to really do siloed unit tests and to better specify the behaviors.
Steps
sm::action::start_<event>_behavior
tosm::action::on_<event>
RobotScheduler
moduleRobotEvents
moduleRobotStates
moduleRobotController
to keep only the actions/callbacksRobotBehavior
module