wood burning stoves*
The moose likes OO, Patterns, UML and Refactoring and the fly likes Simple aggregation & association question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Simple aggregation & association question" Watch "Simple aggregation & association question" New topic
Author

Simple aggregation & association question

Jes Sie
Ranch Hand

Joined: Jul 24, 2001
Posts: 188
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


Thank you.<br /> <br />- Jess Sie<br /> <a href="mailto:jess@see-consulting.com" rel="nofollow">jess@see-consulting.com</a>
Adrian Ferreira
Ranch Hand

Joined: May 29, 2000
Posts: 118
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

Joined: Jul 11, 2001
Posts: 14112
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.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Simple aggregation & association question