UML CLASS DIAGRAM: FITNESS TRACKER

2019-07-26 14:20发布

问题:

Hey I am new to making class diagrams and I am assigned to make a simple class diagram for a fitness program my team is going to develop.

I am good with making the classes and attributes. I am having a problem with the relationships part of it, aggregation and all of that good stuff.

Here is a simple run down: There is a trainer, and each trainer has one client. There is a before and after report for each client. Also there is a daily workout regiment, weekly prescription and logs, for each client.

I have added a image of a rough draft of what I have already.

回答1:

first there is no any specific attribute between client and trainer to make the relation, the association is okay, but there is no any way to find out the client from the trainer or vice versa.
you may need to understand and use the relations between members by asking some question.
so let's start with trainer.

Trainer
Q:do you find a client by its trainer or vice versa?
A[0]: the client is found by its trainer (trainer->client) => so in this case you need to track(have) the client reference inside the trainer.

A[1]: the trainer is found by its client (client->trainer)

A[2]: both trainer and client should have references from each other


the above scenario is true about (after/before)reports and client.

DailyWorkoutSheet
So here each client would has more than 1 workout sheet, so here we have Aggregation and Composition and the difference is not to much hard to understand.
Composition: it means Client has a list of DailyWorkoutSheet and the life-cycle of DailyWorkoutSheet is DEPENDENTS on Client life-cycle, it means if Client get delete(removed from memory), then this will causes to remove all references of DailyWorkoutSheet(s) which have associated to the Client reference.

(the composition shape is a FILLED diamond which points to the class which host(client) the guests(DailyWorkoutSheet))

Aggregation: it means Client has a list of DailyWorkoutSheet and the life-cycle of DailyWorkoutSheet is INDEPENDENTS on Client life-cycle. so it means with removing the Client reference, the DaileyWorkoutSheet(s) which have been associated to the Client reference will persist.

(the aggregation shape is a EMPTY diamond which points to the class which host(client) the guests(DailyWorkoutSheet))



the above scenario is true about the relation between Client and WeeklyPrescription and Logs.



标签: uml