Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Class Operations/Methods - Assignning Problems

Status
Not open for further replies.

trystano

Programmer
Apr 14, 2004
1
US
Hi all,

I seem to be a little confused over what probably is something very simple. I am a little confused as to where exactly I should place some operations within my class diagram. An example scenario is....If I have a 'Staff' class in a Library System and a staff member is able to carry out operations to update the library catalogue (IE add book, delete book, add new book copy etc), where exactly do I put these operations? Do they go in the 'Staff' class, or do they go in the 'Book' class?

Thank you in advance

Tryst
 
Tryst

Neither. Assuming that the catalogue is a collection of items, it sounds like the methods belong in the Catalogue class.

The Book class doesn't really have much to do with these methods, apart from getting added to or removed from the collection. The Staff class may have some involvement (perhaps an isAuthorised method to check security), but the bulk of the action occurs on the class that holds the collection of books.

Also, you might want to consider using polymorphism on the Book class, giving it a superclass of LibraryItem for example, or maybe having it implement an interface like ICatalogueItem. Then you can have more than just books in your library, maybe DVDs, periodicals, VHS tapes, etc.

Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top