java - Is a entity class can return some other entity instance in OOAD? -
this question has answer here:
- ooad design issue 4 answers
i have 2 classes:
public class car { private int id; private string name; private string vendor; /* ... */ } public class garage { private int id; private string name; private string address; /* get-set , others stuffs */ public boolean addcar(car c) { /* insert car tblcars belong garage */ } public list<car> getlistcar { /* perform select query on tblcars choose cars belong garage */ } } is allowed in ooad?
allowed? think going happen - ooad cop pull on side , give ticket?
you can want. you'll find out if it's misguided after fact.
your design looks acceptable, except garage not have collection<car>.
this one-to-many relationship between car , garage. that's how it's done.
i think smalltalk mvc ideas little outdated. here's how see layers web app:
view-->controller-->service--+-->persistence | +--> model controller , view , tightly coupled together.
the service thing knows daos , model objects. fulfill use cases , own units of work.
Comments
Post a Comment