File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Simple aggregation & association question

 
Jes Sie
Ranch Hand
Posts: 188
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear people,
I was just doing some modelling and I found that aggregation and 1 to many association really has got no big diff...especially in implementation via Java.
Example: -
1 1..*
Person <>---------- Address
1 1..*
Person ------------ Address

Both seems to end up with having
public class Person {
private Vector addresses //consists of Address
}

Please give me your input. Is this because of lack of sleep or am I discussing something interesting here?
------------------
Thank you.
- Simon See
simon-ivy@usa.net
-after office hours-
necro-mani-cide
 
Adrian Ferreira
Ranch Hand
Posts: 118
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Simon,
In fact both models can be mapped for this code.
As Fowler in UML Distalled: "Attributes are very similar to associations." So your second example is not wrong.
But, association can also use other options. For example, you can create an Address class with methods like setAddress() and getAddress(). This is is not the better option but also represent that association.
No your first example:

1 1..*
Person <>---------- Address

IMO, this option is more descriptive since you express that an Address is part of Person, not just related to Person.
But this is not always clear. Again UML Distilled: "in the pre-UML days, people were usually rather vague on what was aggregation and what was association". Try to read chapter 6.
I hope it helps,
Adrian


[This message has been edited by Adrian Ferreira (edited August 21, 2001).]
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Simon See:
I was just doing some modelling and I found that aggregation and 1 to many association really has got no big diff...especially in implementation via Java.

Notice that UML is not only used to guide implementation, but also to document intent/meaning. So it's ok that not every detail of a diagramm has its discriminating influence on implementation.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic