• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Class Diagrams -- Design vs Reality

 
Ashwin Pai
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a basic question on class diagrams.
I am doing my SCEA part2 assignment and had this doubt.. I will try to illustrate it with a similar scenario..
I have a EMPLOYEE table and ADDRESS table. EMPLOYEE table has a column ADDRESS_ID foreign key to ADDRESS.ADDRESS_ID.

Now in my object model 1 Employee can have 1 Address.

So when i did my Class Diagram, I had an Association from Employee.

My question is
When i code the class, do I have to add the Address object in the Employee class? or
Could I just do with a class memenr addressId ?
If I do it the 2nd way is my class diagram incorrect ?

I feel this is even more important while using EJB3 JPA. while loading the Employee object, EM would also load the Address object vs Just loading the address Id(if 2nd approach is taken).

Let me know your thoughts!!

Thanks
Ashwin
 
Hong Anderson
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Best practice is traversing to Address via Employee object. That means, I prefer to have Address reference in Employee (not just Address Id).

So we can interest only about Employee which is the root of Aggregate (you'll understand what I say, if you have read DDD).

I believe EJB 3.0 has lazy loading option which will load data when needs.

Anyway, I think you interest in too minor point, what you ask is a very little point in architecture and design.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic