Here is a simple question about my UML lesson's homework, and I'm not sure about what I've done. Could you help me to get it corrected,I will be so grateful for yours kinds advices:
The exercise is to design a class structure for a library system. It should fulfill those requirements:
Here is the UML diagram that I made:
At first sight, the diagram corresponds to the narrative, with some comments:
Borrow
class could be called Borrowed
or History
; having two borrow
on the same diagram for different purpose is a source of confusionborrow
shows that at a given moment a maximum of 4 books are borrowed. But the minimum should be 0 ( no library user is obliged to always have a book). Reciprocally not all books are borrowed at a moment in time: so it’d be 0..1Now the diagram raises some question:
I didn’t follow your course, so I don’t know what the teacher expects. But here is how I’d modelled it:
borrow
association with an association class Another problem is included in the narrative: what is when an underage user becomes adult ? Your realization relation implies that two different users would exist for the same person (the new adult would loose the history).
For this reason, I’d suggest to use composition over inheritance: make user
a full class, compose with an Identification
, and make two concrete classes adultIdentification
, underageIdentificztion
. So when an underaged user becomes adult, you keep user with history and change only the means of identification :-)