Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I have created a class hierarchy for an inventory system for a book/magazine. Here's the picture:

enter image description here

Will it do? I know there's no magazine class yet but I was wondering if anyone could suggest a better idea.

share|improve this question
4  
This belongs in CodeReview.SE. –  Yam Marcovic Dec 17 '11 at 12:56
    
@YamMarcovic Actually I'm not really sure it belongs at CodeReview. Even if it did, it's also on topic here, so no point in migrating. –  Yannis Rizos Dec 17 '11 at 13:37
1  
Visual Paradigm offers a free UML tool. I'd suggest you use that instead of the Community Edition, so your diagrams won't have the ugly watermark. Also, you could look at floss uml tools, of which I highly recommend StarUML and ArgoUML –  Yannis Rizos Dec 17 '11 at 13:40
    
@YannisRizos General theoretical design questions belong here, but what you're seeing here is essentially code, it's just presented in UML. It belongs in Code Review. –  Yam Marcovic Dec 17 '11 at 13:58
1  
@YamMarcovic I'd love it if it belonged at Code Review, I'm with you - class hierarchies make much more sense there than here - but checkout the meta discussion I've linked at my previous comment. There are other meta discussions that touch the subject, none with an accepted answer - so we can assume the discussion is still open. But as it stands, Code Review is for code, excluding code diagrams. –  Yannis Rizos Dec 17 '11 at 14:00
show 6 more comments

closed as too localized by Loki Astari, kevin cline, DKnight, Walter, Mark Trapp Dec 19 '11 at 4:02

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

3 Answers

up vote 2 down vote accepted

If it's a case of just UML homework, Yannis and Emmad are spot on with regards to technical aspects and you just re-model it with their input.

Coming to the functional part, my suggestion would be

  • Visit Barnes and Noble and follow the links to get a better understanding of how book sites function. You got to know it to model your system
  • You cannot have the same class hierarchy for books and magazines. They are inherently different. Think books with author, publisher and magazine with articles, author.
  • Create entirely separate classes for inventory and users. They are different entities.

Dear John, you must think a bit realistically when it comes to modeling. You can follow this link to get a better understanding. You may just skip the XML part. It would also teach you a few more things

share|improve this answer
    
+1, good advice regarding magazines and books as well as visiting a site. –  Emmad Kareem Dec 17 '11 at 14:18
    
the thing is How would I seperate the books from magazine, do i need to make a different class for each? or just create a catagory? . still on the verge of quitting with this. –  Kyel John David Dec 17 '11 at 14:29
    
Separate classes are preferable. –  Ubermensch Dec 17 '11 at 14:48
    
Your classes would be User, Book, Magazine, Inventory, Author and Publisher. You can't have fewer than this even if it's an example. Else, just have a Book, Inventory and User class, add a category and map your enumerations to the book class as variables rather than properties. Authors and Publishers are part of book so they just can't be treated as properties. –  Ubermensch Dec 17 '11 at 15:01
    
One thing, can I just create. a Book class which has an attribute of Author,ISBN number on the book class with Price and qty? while on the magazine class has a ISSN number and BNID number?. I created a class called Product Details. where in this class it has the Publish date,Genre,SalesRank and number of pages? –  Kyel John David Dec 17 '11 at 15:05
show 5 more comments

I am not sure if this is a homework or a real system. Anyway, I see that it is missing a lot of things. Models for real applications must be comprehensive and complete.

The purpose of the system must be identified so that it can be judged. Any way, several things are not correct with this model. I will list some of them only:

  1. The classes: Authors, BookTtiles, PublishingCo. should not be made of static values. Each should be a separate class with association to book class.

  2. The naming should be checked. For example you should not have a "." in a name as in "PublishingCo."

  3. User information is in a class called Counter! Why is that? Also, make sure the password is not strored as a readable text string.

  4. "stocks" property of the book class should probably be calculated from a sales, inventory, returns and similar tables.

  5. The model does not show distinction between magazine and book. You should consider a publication class with magazine and book inheriting from it (there are other solutions of course)

  6. Association between inventory and book is ambigious to me.

  7. Class BookProperties, is ambiguous. A book/magazine have very clear properties that are not shown anywhere.

  8. Identifiers in the model are not obvious.

I think you should spend sometime studying modeling.

Edit - In response of some questions in comments: I assume that this model is a simple model used for training, so I am simplifying things a lot here. This type of modeling is a "data first" type that is based on a relational view not on an OO view.

  • Have 2 separate classes one for Magazine and one for book (correctly suggested by @Ubermensch)

  • Some useful properties of book are: ID (sequence number generated by database), Title, ISBN, BookEdition (A book has 1 or more editions but we simplified the case by having the ISBN same for all and the publisher the same for all), LastPublicationYear and Price.

Note the following associations to separate classes:

  • BookLanguage (lookup): A book is published in 1 language (simplified rule)

  • Author (lookup): A book has 1 or more authors. In reality, a book could be authored by 1 or more authors, each could author other books which will complicate your model, assume a book author does not repeat in the database for simplicity.

  • A book itself is not the unit of transaction. The unit of transaction is a "BookCopy". So you need a "BookCopy" class. A book is transacted via zero, one or more "BookCopies". In the "BookCopy" class. Add a Transaction class where you could record TransactionDate and TransactionType. TransactionType is looked up on TransactionType Class (lookup) that would contain values such as: Sold, Recieved, Damaged. You can then count the inventory quantity of any book by calculating the available quantity = (Sum of Received - Sum of Sold - Sum of Damaged). Since the value is calculated, it needs not be stored.

Each of the items marked as (lookup) will have an ID column (auto generated by the database) in their respective calsses. As a result of associatiation with Book class, there will be a Foreign key of that ID.

Some references that may help you from Google Books:

Google Books - Introduction to Database Systems - 1

Google Books - Database management systems - 2

share|improve this answer
    
this is more of a homework. not an actual system. I am just practicing my abilities with modeling. what are some properties of a book?? @Emmad Kareem –  Kyel John David Dec 17 '11 at 13:53
    
+1 But could you please use the markdown list syntax? Either by hand or via the WYSIWYG editor. I've seen you making lists by hand in other posts, and it's a very minor thing, but since posts are supposed to be editable by anyone you should prefer the dynamic markdown syntax: If I decide to add an item to your original list I would have to renumber every item after that. Also the markdown syntax translates to list oriented CSS, which may not make much difference when viewing the post via a desktop browser, but they are quite important when viewing via mobile.. –  Yannis Rizos Dec 17 '11 at 13:58
    
can we just keep it simple. it is not yet to be made into a real System. I am just practicing. kindly post a student friendly answer. –  Kyel John David Dec 17 '11 at 14:08
    
@YannisRizos, thanks for the comment. I will take care of that in the future. –  Emmad Kareem Dec 17 '11 at 14:16
    
@KyelJohnDavid, are you practicing programming with classes or UML or modeling in general so that we could try to help? If you are practicing programming a simplified model could be used. If you are practicing modeling, a good model must be prepared. –  Emmad Kareem Dec 17 '11 at 14:20
show 10 more comments

In contrast to Emmad, I see a lot of things you don't need. There's no point in developing any kind of UML model until you have specific use cases to drive the modelling. If you just need to do inventory management, then you don't need information about price, or genre, or even author. You need some identifier (ISBN?), the reorder policy, and the source.

If you start modeling before collecting use cases, the modelling will take forever. That's not an exaggeration. I once joined an team at an airline that had been modelling for two years (Software through Pictures), somehow imagining that they were going to be able to produce a single model for the entire company. Finally the customer got impatient and wondered when this team was going to deliver some value. So we identified a real problem, and got down to the hard work of producing a working application. For some reason, the modelling team decided to find something else to do. We never did get any value from the two years of modelling.

share|improve this answer
    
I agree with your opinion regarding the need to define use cases (or at least an objective) first. I tried to extract some sort of information on the purpose of the model, and it looked like it is some sort of training (could not identify for what exactly, although I asked) - Your experience with the airline case is interesting! –  Emmad Kareem Dec 17 '11 at 19:51
    
Good point, broaden up my mind, but the thing is I am just practicing with UML modeling, that's it. I already know how to design/create use case diagrams. This is just for the purpose of learning this Class diagram, since I found this as my weakness when it comes to designing. but thanks for the feedback. –  Kyel John David Dec 17 '11 at 23:34
    
@KyelJohnDavid: what sort of weakness? You don't understand the diagrams, or the classes you think you will need turn out to be the wrong ones? The solution to the second sort of problem is to not create classes except as needed to satisfy some use case. –  kevin cline Dec 18 '11 at 1:03
add comment

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