The current implementation uses AccelerometerService to utilize the instance of StepDetector, which might not be how I would like it to be.
Considerations
I will examine the Singleton and Observer patterns to determine what would be best for the AccelerometerService. This would allow future functionalities that need to subscribe to its events.
I will add an intermediate class, named something-handler, to manage the logic related to the user's steps.
Renaming some of the classes when we are at it to align with the new direction of measuring the number of steps and additional features.
In consideration of coupling, testability, and modifiability, I refactored quite a bit and changed the instantiation and flow of data.
Modifications
I have stript the AccelerometerSerice class of additional features. It simply starts and stops the monitoring of the accelerometer and the classes that will utilize it will subscribe to AccelerometerDataReceived.
I created the ExerciseManager which is instantiated with two instances from the ExerciseViewModel:
The StepDetector as the detector.
The AccelerometerService as the service.
The StepDetectorState is also retrieved in the view model from memory and is passed to the StepDetector before initiating the ExerciseManager. This allows the state to work as a parameter between the ExercisePage and the SettingPage which will lead to a direct update of the values for the session. This will result is less load and save to the devices memory and make the adjustments more seamless.
The current implementation uses AccelerometerService to utilize the instance of StepDetector, which might not be how I would like it to be.
Considerations