Sunday, 26 May 2013

Where should I put my method

Where should I put my method

I am writing a Java program using the MVC design pattern.
I have classes Item and Supplier. In the database they are connected through a item_supplier table.
I'm writing a method which will give me all suppliers for a specific item (using itemID):
public ArrayList<Supplier> getItemSuppliers(int itemID)
I have a DB layer as well and I have DBItem and DBSupplier. Where should this method go? I will use it only (mostly) on my ItemUI so I am thinking of DBItem as the correct place.
--
Usually when we have the SalesLineItem pattern (Sales * - 1 SalesLineItem 1 - * Item) we have a separate class, but in that case, do I need such as my only interaction with that table (item_supplier) will be with this printing (and one updating) method?
Basically, do I need to do a ItemSupplier model layer class and respectively DBItemSupplier or can I just have those two methods getItemSuppliers and updateItemSuppliers on either DBItem or DBSupplier (and if the latter, where?)

No comments:

Post a Comment