Search code examples
umlclass-diagramclass-design

Classes for class diagram UML


I am currently studying an example from an online course to design a class diagram for a Library Management System.

However, I am confused with this example: enter image description here

I can't really understand the purpose of creating two classes: Book and Book Item. Couldn‘t I just insert attributes from Book Item class into the Book class and keep only a single class of the two?


Solution

  • This is an interesting example:

    • The Book refers to an book in the catalogue of the publisher or the library. It has an ISBN to uniquely identify it, a title, an author and so on.
    • The BookItem refers to a copy of that book that is owned by the the library and is lend to the users.

    But this example requires improvements:

    • the model should prefer composition over inheritance., which in UML translates tonprefering a simple association over a specialization. Several BookItems may refer to the same Book, and the model does not capture this reality.
    • The boundaries between book and book items need to be reviewed. For example the BookFormat (only in item) may in reality influence the number of pages (in book). Moreover a publishing date seems not to be specific to a book item but general to the book. Printing date could change on each item.