nus-cs2103-AY2324S1 / forum

10 stars 0 forks source link

Difference between association and navigation #548

Closed s-peiran closed 11 months ago

s-peiran commented 11 months ago

Definition of Navigation from the textbook:

image

Definition of Association from the textbook:

image

If both association and navigation requires one class to keep a reference to another class, then what differentiates them?

TeeRenJing commented 11 months ago

I think every association between two objects/classes has a navigability (Unidirectional or Bidirectional), and you can choose to include this information by adding arrowheads in the UML diagram. So I think navigability is a trait of the association, not something different from an association.

Much like how a road can be one way or two way.

image

damithc commented 11 months ago

Much like how a road can be one way or two way.

Good analogy @TeeRenJing 👍

s-peiran commented 11 months ago

@TeeRenJing thanks for chiming in.

s-peiran commented 11 months ago

I want to follow-up this qn that whether navigability and association arrows can be used interchangeably. image Taking the practice exam for instance, can all the navigability arrows (such as that from activity to watcher) be replaced with association arrows?

damithc commented 11 months ago

Taking the practice exam for instance, can all the navigability arrows (such as that from activity to watcher) be replaced with association arrows?

@s-peiran There is no such thing as an association arrow. Association is the line ____, navigability is the arrowhead >

s-peiran commented 11 months ago

I meant whether it is technically correct to show navigability as association line? The navigability arrow is just a more specific representation of association that shows the direction of reference.

damithc commented 11 months ago

I meant whether it is technically correct to show navigability as association line? The navigability arrow is just a more specific representation of association that shows the direction of reference.

Think of navigability, multiplicity, association label, and association role as additional information you add onto an association. They don't exist without an association.

s-peiran commented 11 months ago

thank you for the clarification prof.