The Artima Developer Community
Sponsored Link

Java Answers Forum
Association Problem

2 replies on 1 page. Most recent reply: Jun 5, 2005 12:28 AM by Shashank D. Jha

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Association Problem Posted: Jun 2, 2005 6:49 AM
Reply to this message Reply
Advertisement
If I have a class as follows:


classA{
int att1;

public boolean someMethod1(packageb.ClassB b){
process(b);
return false;
}
}


Is it fair to say A is associate with B, if B were an attribute, then
we would say A has to have a B object, am I right??

Thanks for your assistance.

Spike


Amol Brid

Posts: 43
Nickname: amolbrid
Registered: Feb, 2004

Re: Association Problem Posted: Jun 3, 2005 5:17 AM
Reply to this message Reply
Yes you are right, there is a association between A and B.

If B is a member of A then there can be two types of associations:
1) Aggregation, lifetime of B is not controlled by A, and
2) Composition, lifetime of B is controlled by A, means A is responsible for creating and Destroying B's object.

Second point was not clear to me.

Regards,
Amol Brid.

Shashank D. Jha

Posts: 68
Nickname: shashankd
Registered: May, 2004

Re: Association Problem Posted: Jun 5, 2005 12:28 AM
Reply to this message Reply
responding to Kondwani

> If I have a class as follows:
>
>

> classA{
> int att1;
>
> public boolean someMethod1(packageb.ClassB b){
> process(b);
> return false;
> }
> }
>

>
> Is it fair to say A is associate with B, if B were an
> attribute, then
> we would say A has to have a B object, am I right??

Case 1:
Whenever two objects communicate with each other they are associated. So that way you are correct that A and B are associated.

Case 2:
You are further correct that when A has object of B as one of its attribute.

Case 1 kind of association, as reflected in your source code is basically termed as "dependency" relationship in UML.

Case 2: kind of relation as mentioned theoretically is basicaly called as Associaiton relation in UML.

regards,

------------
Shashank D. Jha
iCMG
e-mail : shashank@icmgworld.com
Phone : +91-80-98451 87302

Flat View: This topic has 2 replies on 1 page
Topic: How to fetch data from TV tuner card Previous Topic   Next Topic Topic: GRINDER 3 load without GUI

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use