Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

General Association V/s Composition/Aggregation

 
Sridhar Raman
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Is there any distinct advantage in modeling a relationship as a composition/aggregation as opposed to a general peer-peer relationship?
For example, I can use relate CreditCard and Customer as:
1. Customer uses CreditCard or
2. Customer has CreditCard
Are there some things to be considered in choosing one of these two approaches? What are the pros and cons of the two approaches?
Any insights, please?
thanks in advance
Sridhar
 
venkatesh rajmendram
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sridhar Raman001:

For example, I can use relate CreditCard and Customer as:
1. Customer uses CreditCard or
2. Customer has CreditCard


In 1. when customer Object dies creditCard object is still alive, In 2. When customer object dies creditCard Object dies in case of composition. In case of aggregation it remains.
pick your battel...
that might help.
- Venkatesh
 
Sridhar Raman
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your explanation, Venkatesh.
I was looking for an explanation from an architecture/design perspective and not from a construction/destruction perspective. In the sense, I was trying to find out if there are any inflexibilities posed by these approaches, which approach provides more room for changes, etc.
For example in OOAD, composition is preferred over inheritance, because composition offers a more flexible approach whereas inheritance results in tighter coupling. I was looking for answers from this perspective.
Any further thoughts on this?
thanks
Sridhar
[ July 18, 2003: Message edited by: Sridhar Raman001 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic