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.
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 otherthe 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 meansClient
has a list ofDailyWorkoutSheet
and the life-cycle ofDailyWorkoutSheet
is DEPENDENTS onClient
life-cycle, it means ifClient
get delete(removed from memory), then this will causes to remove all references ofDailyWorkoutSheet
(s) which have associated to theClient
reference.(the composition shape is a FILLED diamond which points to the class which host(
client
) the guests(DailyWorkoutSheet
))Aggregation:
it meansClient
has a list ofDailyWorkoutSheet
and the life-cycle ofDailyWorkoutSheet
is INDEPENDENTS onClient
life-cycle. so it means with removing theClient
reference, theDaileyWorkoutSheet
(s) which have been associated to theClient
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
andWeeklyPrescription
andLogs
.