UML Extension

Classes Relationship in UML

Association

"Association" on behelf of the reference between Class A and Class B.  Association allows one class to know the methods and attributes of referenced class.

Normally, referenced Class is attribute of host Class.

One-direction asscociation:

Class A know methods and attributes of Class B, but class B does not know the existing of Class A.

Bi-direction asscociation:

Both Class A and Class B know methods and attributes of each other.

Dependance and Association

"Dependance" is another kind of "Association",  the difference is that:

  • The referenced Class in Dependance is not global level filed/attribute/property of host Class.

Aggregation and Composition

"Aggregation" and "Composition" descript a relationship between "Entire" object and its "Sub Elements":

  • The "Entire" is a composite of all the sub elements.

Difference between Aggregation and Composition

  • Composition manage the life cycle of sub-elements: Sub-Elements initialized along with Entire Objet initialization and they are cleaned along with Entire Objet destroied.
  • "Entire" part in Aggregation do not manage the life cycle of "sub-elements" part.

Aggregation and Association

Referenced Class/Classes in both Aggregation and Association are implemented as class' attributes. The atttibute could even be implemented as a collection:

Car.java:

List<Wheel> wheels;

People.java:

List<Car> car;

We can say: car is aggregated by wheels. But we cannot say People is composited by cars.

UML in my projects

Descript how I use UML in every day's development.

To Be updated.

猜你喜欢

转载自george-gu.iteye.com/blog/1288342
uml