Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Cade's Class Diagram question... Please Help

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello everybody,

I started struggling with the part II today and when I looked at the class diagram in the Sun's SCEA book, I noticed two things:

- Address has an unidirectional association to Customer. The navigability arrow is at the customer side, meaning that the responsibility lies on the address object. Shouldn't that be the opposite? Shouldn't a customer have a collection of addresses (home, business,shipping1, shipping 2, etc.) instead of each address having a instance variable to customer? I don't get it.

- Credit card is the same; it also has an unidirectional association to Customer.


Please help!
 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Alex,

- Address has an unidirectional association to Customer. The navigability arrow is at the customer side, meaning that the responsibility lies on the address object. Shouldn't that be the opposite? Shouldn't a customer have a collection of addresses (home, business,shipping1, shipping 2, etc.) instead of each address having a instance variable to customer? I don't get it.

- Credit card is the same; it also has an unidirectional association to Customer.


Both your approach and Cade's approach is correct. You can keep customer info in a Address or you can keep Address info in a Customer. Remember you are just looking 2 classes here. When you will have 20+ classes in the class diagram, your design needs to be consistent.

Here is my recommendation - Go ahead and start the design the way you think. As you add more classes to the class diagram, some of the design choices you made earlier may be challanged and you probably will be forced to change the design again.

Good Luck.
 
Alex Silver
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sudhansu,

Thank you for your reply! I feel better now!

Alex

Originally posted by Sudhansu Pati:
Hi Alex,

- Address has an unidirectional association to Customer. The navigability arrow is at the customer side, meaning that the responsibility lies on the address object. Shouldn't that be the opposite? Shouldn't a customer have a collection of addresses (home, business,shipping1, shipping 2, etc.) instead of each address having a instance variable to customer? I don't get it.

- Credit card is the same; it also has an unidirectional association to Customer.


Both your approach and Cade's approach is correct. You can keep customer info in a Address or you can keep Address info in a Customer. Remember you are just looking 2 classes here. When you will have 20+ classes in the class diagram, your design needs to be consistent.

Here is my recommendation - Go ahead and start the design the way you think. As you add more classes to the class diagram, some of the design choices you made earlier may be challanged and you probably will be forced to change the design again.

Good Luck.

 
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I also have a question about Cade's class diagram, there is an unidirectional association from Product to ProductCategories. if that is the case, how can we make product search in the ProductCategories? I also confused with the name ProductCategories and the multiplicity many-to-many, if ProductCategories reprentes a set of structured categories, it seems no need to be many-to-many.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic