Then the problem is that there are many ways to implement them, and the code doesn't even necessarily look differently. The difference between the three concepts is much more in the intention than in the structure of the code.

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

sita raman
Ranch Hand

Joined: Jul 10, 2005
Posts: 33

posted Aug 22, 2007 22:18:00

0

Please advice whether my concept is correct.

Association is similar to the HAS relationaship.ie one class have the reference of the other.

Class A{ B b; }

Aggregation is the collection of reference.

Class A{ Vector v1;//contains the collection of reference A. }

Composition is one which cretes and detroy the othe rererence.

Class A{ B a=new B(); }

Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112

posted Aug 23, 2007 01:45:00

0

Actually, every single of those examples could be either Composition, Aggregation or simple Association. (Although the probability for the last to be Composition might be a bit higher.)

It really depends on what the code that you haven't shown does with the object, and *why*.