Forums Register Login

Class Diagrams -- Design vs Reality

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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.
Everyone is a villain in someone else's story. Especially this devious tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 982 times.
Similar Threads
class diagram objects vs. sequence diagram objects
Association + Multiplicity vs. Aggregation vs. Composition
subclass vs compostion
JPA: Secondary tables +optimistic locking
Class vs Component diagrams: Level of detail & scope
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 07:45:31.