Classes Relationships

Hi everyone

I am new to OOA and OOD and in UML.I must clarify these concepts in my mind.

-Association

-Composition

-Aggregation

-Dependancy

-Is Association a superset of Aggregation and Composition?

Can anybode give me any links or examples how these are implemented in Java?

[324 byte] By [Katsouranis75a] at [2007-10-2 2:51:48]
# 1

> -Association

One class knows about the existence of another and may address it directly by it's name.

> -Composition

Composition is a specialisation of an Association with a lifetime constraint. It means that once class is made up with one of more other classes. A Car is a composite of a Body, an Engine, a Gearbox, etc. The lifetime of all, and coupling is implicitly the same. e.g. Without these it is not really a car. This is sometimes said to be a static relationship.

> -Aggregation

Composition is a specialisation of an Association without a lifetime constraint. It is a much more dynamic relationship. One class is a container for other classes, the other classes may be added or removed from the container as required. The lifetime of each is independent. e.g. A Car's relationship to a driver & passengers.

> -Dependancy

Dependency is an artifact of compile or link time interface resolution and checking. A change to the interface of dependancy target will result in a change to the depemdant.

> -Is Association a superset of Aggregation and Composition?

Yes.

> Can anybode give me any links or examples how these

> are implemented in Java?

I suggest you download a trial or free UML tool, and try them for yourself. Try different relationships, different multiplicity and examine the generated code.

MartinS.a at 2007-7-15 21:14:26 > top of Java-index,Other Topics,Patterns & OO Design...