Question about UML class diagrams of library

Kaining xin :

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:

  1. There are two types of users - under-aged and adults.
  2. Under-aged users are identified with usage of their full name and student card.
  3. Adult users are identified with usage of their full name and ID card.
  4. The library contains books.
  5. There is basic information about every book (title, author, etc).
  6. The user can borrow at most 4 books at the same time.
  7. There is a history of previously borrowed books for every user (along with all the dates)

Here is the UML diagram that I made:

enter image description here

Christophe :

At first sight, the diagram corresponds to the narrative, with some comments:

  • The Borrow class could be called Borrowed or History; having two borrow on the same diagram for different purpose is a source of confusion
  • This class would need all the dates: sonthe start of the borrowing and the return if the borrowing.
  • The association borrow 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..1

Now the diagram raises some question:

  • does a book that is currently borrowed already appear in the history with an empty return date ?
  • if not, how do we keep track of the borrowing start date.

I didn’t follow your course, so I don’t know what the teacher expects. But here is how I’d modelled it:

  • I’d used a many to many borrow association with an association class
  • the history information would be in the association class
  • the limit of maximum four books borrowed would be expressed with a constraint.

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 :-)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=25286&siteId=1