I have an old project made i Java.
It is a library-system in which you can create book-objects and customer-objects.
You save the objects in a List.
Now when you are going to make a loan, here is how it worked in my old Java-project.
I had a class loan-handler. In that class I had a method where I sent a string ISBN (the book the customer would like to loan) a id string for the customer (the one to loan a book of course) a List of books and a List of customers.
In the method I would save the customer-object in a variable in the book-object so I know who have loaned the book.
The customer-object have a List in which you save the book that the customer would like to loan.
Hope I made it clear.
Is this good OOP-design? Is there a better way?
Should I have a loan-handler class?
Loading
Lars PerssonPosted Apr 9, 2012, 11:31 AM
I made it in a university-class for Java, and the focus was on OOP. To reatain the list it was saved using a stream and then loaded back.
I suppose you also could use LINQ to save the objects.
But my questions are these:
Should I make a class that handles the loan?
Also in the loanHandling-class I have a method where I send in (corrected in the original question) a string ISBN for the book to loan and a string Customer-ID. I also send in the bookList and the customerList.
Using the ISBN and Customer-ID I look upp the right book. In the book-object I have a variable of type customer-object. In that variable I save the customer-object so I know who lended the book.
In the customer-object I have a List where I save all the books that the particular customer lends.
Maybe not so clear.
My question was if that is a good design. I realise that there are many ways to solve this.
Sam HobbsPosted Apr 9, 2012, 10:51 AM
You will need at least a table of books and a table of customers. Another table might be a table of loans for a book. You might also have a table of books borrowed by a customer.
Consider the relevance of an order entry application. In an order entry application, there is a table of inventory items and a table of customers and a table of orders. Your application seems similar. In an order entry application when an order is created first the customer is selected. Then inventory items are added to the order. For inquiry purposes you could have a form showing customers, another for books and another for loans.
Does that sound relevant? Is that like the way your previous application worked or is it significantly different? If it is significantly different then do you want to still do it like the previous application?