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 case product , customer)
  • basepackage.dao: contains daos, only used access data, 1 per entity, each 1 containing methods such findall() : 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 (or basepackage.web webapp): contains hmi/web services/... implementation.

Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -