1

I am going over tutorials regarding class design; in one, a videotape can have multiple copies and each copy can be borrowed by a borrower. Please see figure A:

enter image description here

I am trying to understand why the answer in Figure B, which considers copy as an attribute would be wrong. My only guess is that then I could only represent one copy of each videotape. Since each instance of my videotape class, represents a single videotape (e.g. Pink Panther Movie). But if I want to show two borrowers can borrow multiple copies of Pink Panther then I can't with a videotape class that has copy attribute. Please help me understand the difference.

PS. I truly hope this message will not get negative votes as I am really confused and need to learn this information for an upcoming test.

12
  • 3
    In my personal opinion, neither of the two makes much sense. But it doesn't matter what my personal opinion, or your personal opinion, or the personal opinion of anyone other than your teacher is, because it is the teacher who grades the test, not me. So, the only person who can tell you why they think A is correct and B is wrong is your teacher. Commented Nov 11, 2021 at 8:59
  • Thanks. But I do not have access to the instructor for some time. Moreover, I think there are some guidelines with class design, but I am not aware of them.
    – Afia R. S.
    Commented Nov 11, 2021 at 9:00
  • Please note a similar concept is used in the slides slideplayer.com/slide/14797489 Where a book has copies (in the sequence diagram)
    – Afia R. S.
    Commented Nov 11, 2021 at 9:04
  • 2
    How would you represent this with a videotape class with a copy attribute? Don't forget these diagrams are ways to talk about programs - we don't just draw diagrams for the sake of drawing diagrams. How would you program the second one? Commented Nov 11, 2021 at 10:02
  • 3
    This does not seem to be an easy conception of the situation. You would not have "videotapes" and "copies" - you have films (representing the abstract information, like the title and cast), you have videotapes (representing the physical copies on hand), you have a set of stock accounts (one for each member/borrower, plus an account for the shop itself, representing which tapes are currently in whose hands), and then you have a journal that records the movements between each account (issues from the shop to the member, returns from the member to the shop, etc.).
    – Steve
    Commented Nov 11, 2021 at 10:24

1 Answer 1

3

Either of them could work, depending on what you want to achieve.

Remember that a class is not an object. You can have multiple objects of the same class. So if you're adopting the model of Figure B, you will have multiple Pink Panther movies, all identical except for their copy number, which would be unique for each. Each borrower borrows one copy, and the rest can be borrowed by other people.

The main disadvantage of Figure B, is that each copy of the Pink Panther movie will duplicate the same data for cast, crew, year etc. By splitting that out, as in Figure A, you can store the common information in one place and each VideotapeCopy only has to hold its copy number.

In general, there is no one correct solution to a software design. It's about finding the best trade-offs.

Minor quibble: Shouldn't the cardinality of the Borrower end of the relationship be 0..1? You can have a copy that isn't currently borrowed by anyone.

2
  • Thanks. I guess one more argument for Fig A would be that ISBN could be the unique attribute, but for B, we need combination of ISBN + Copy. Regarding the borrower, you are correct, but one assumption may be that people may borrow, but borrowers do borrow?
    – Afia R. S.
    Commented Nov 11, 2021 at 15:56
  • made a mistake with ISBN. I think it would be ISAN (a unique identifier for movies)
    – Afia R. S.
    Commented Nov 11, 2021 at 16:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.