I've developed a simple Workout Android app without uml class diagram in mind. Now I want to refactor it.
On the home screen, there's just a button to start an workout session. By clicking on it, a countdown of 10 seconds is fired, waiting for the person to get ready.
Then, the app will display several exercises, one at a time, with a break interval between them. Each exercise takes 30 seconds; and each break interval, 10 seconds. On each exercise/break, the app shows the following information:
Finally, when the workout session finishes, the app shows a GIF as a celebration. On this last screen there's also a "Go home" button.
I've made the following UML class diagram to model this app:
However, I'm not so sure if this is the proper way to model the scenario described. I'd appreciate if I could get some feedback/review about it.
One of the main things that I'm in doubt of has to deal with the WorkoutActivity
class. It has no attributes in the diagram because I couldn't think of any attribute for it in the way that I'm modeling this problem. And because it's empty, it's a little weird to me. I thought about using a list class (e.g. ExercisesList
) to model the set of exercises, but I'm kind of stuck with this diagram.
Another issue is about the buttons, should I include them in the diagram?
It all depends on what you want to represent.
If your model is meant for the domain of workouts, keep it simple: the buttons (the user interface objects) and the timer (execution context) would not be needed.
In the narrative you mentioned a "workout session". I assume that this is what the WorkoutActivity
is about. So better be consistent with the naming.
You can think easily of attributes: it’s the date and time (and user account?) of the session: this could allow the user to follow his/her regularity in the training.
A more general approach would be to have a WorkoutSession
composed of several abstract WorkoutActivity
(caution: different meaning than in your current diagram). Each WorkoutActivity
would be a specialisation: either an Exercise
, a BreakInterval
or a InfoActivity
(e.g. FinalActivity
, but why not also a StartActivity
activity to encourage new users, and other occasional activities such as tips&tricks, or advertisement). Something like:
The constraint of having one break after each exercise does not need to be structural: it can be a constraint that you enforce when the session is composed or generated. This gives you more flexibility, if in the future you’d line to have a break every 2 or 3 exercises (e.g.:advanced users).