java - OOAD Design issue -
i have 2 tables: tblcustomer, tblproduct:
tblcustomer: id: integer, auto-increament name: varchar(30) .... tblproduct id: integer, auto-increament name: varchar(50) customerid: integer .... and 2 classes: customer, product:
public class product { private int id; private int name; /* other stuffs */ } public class customer { private int id; private string name; private string phonenumber; /* get-set , others stuffs */ public static boolean add(customer cus) { /* insert customer tblcustomer */ } public boolean addproduct(product pd) { /* insert product tblproduct current customer id */ } } when customer register account, call:
customer cus = new customer(/* ... */); customer.add(cus); and when customer buy product:
product pd = new product(/* ... */); currentcustomer.addproduct(pd); but teacher said not correct in ooad (and oop) because customer.addproduct operate on tblproduct table, right? design case?
** update: ** product haven't pre-defined yet, when customer buy product, store make , delivery customer, 2 same products rare happen, tblcustomerproduct need?
add dao tier contain logical part of methods save, delete, update, etc.
here how do:
basepackage.domain: contains entities (data only, no logical part - in caseproduct,customer)basepackage.dao: contains daos, only used access data, 1 per entity, each 1 containing methods suchfindall() : list<e>,findone(k id) : e,save(e e) : void, etc.basepackage.service: contains services, the logical part of app. services ones calling daos.basepackage.presentation(orbasepackage.webwebapp): contains hmi/web services/... implementation.
Comments
Post a Comment