java - Is a entity class can return some other entity instance in OOAD? -


this question has answer here:

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

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>? -