Question

After some confusion with mixing use case and class diagrams, managed to clear some doubts and come up with the following class diagram. Felt more comfy with this than use case. Hope am not wrong. Would like some feedback on any errors and improvements on it. Thank you.

Question:

A new library has books, videos, and CDs that it loans to its users. All library material has a unique identification number and a title. In addition, books have one or more authors, videos have one producer and one or more actors, while CDs have one or more artists.

The library maintains one or more copies of each library item (book, video or CD). Copies of all library material can be loaned to users. Reference-only material can only be loaned for a maximum of two hours and can’t be removed from the library. Other material can be loaned for up to two weeks. For every loan, the library records the user, the loan date and time, and the return date and time. For users, the library maintains their name, address and phone number.

Draw a class diagram for the description above.

Class Diagram: link to diagram

Class Diagram

Was it helpful?

Solution

  • Don't use notes for multiplicities 1..*. Edit associations or their ends instead and write it there.
  • Write multiplicities on ends, not in the middle of the line.
  • Arrows should be subscribed by names of attributes.
  • Libraries can have many Videos, books, CD's and so on. So, there multiplicities should be in both ends.
  • No arrows on the line is the same as arrows on both ends. Check it on the right sides.
  • Write attributes inside blocks when they are of types not present on the diagram. If they are not, put their names on the opposite ends of the associations, near arrows.

  • You should use some empty diamonds on the left side.

  • You should decide the multiplicity of the producer.
  • Divide Title from Copy. And maybe, from Edition.
  • Don't mix plural and singular - hold to some system. I use plurals only for collections, but you needn't take it, of course. Plurals in class names are senseless - all classes apart from singletones have many instances.
  • You don't need toconnect library to CD and Video - they are merely subsets of Books. And books already are connected. The same with three lists in the Library block.
  • Loan should be connected to Book.
  • According to standards, loan() is a constructor of the class Loan. It can't be in another class.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top