Our team is inconsistent. Some associations are named as verb phrases (teaches, is registered for) and some just have role names on each end (instructor, students).
Both are valid UML. Is there a convention that holds up as a model grows?
Our team is inconsistent. Some associations are named as verb phrases (teaches, is registered for) and some just have role names on each end (instructor, students).
Both are valid UML. Is there a convention that holds up as a model grows?
Role names always. Verb phrase optionally.
The reason is practical rather than aesthetic: you navigate by role name in OCL.
self.students->size() reads well. If you have only named the association teaches, you end
up navigating by class name and every expression that touches two associations to the same
class becomes ambiguous.
The verb phrase earns its place on a diagram meant for a non-technical reader, where
Instructor ──teaches►── Course reads as a sentence. It costs nothing to have both.
Add one more rule: role names are plural when the multiplicity is many, singular when it is one. student vs students tells you the cardinality without looking at the diagram, which matters when you are reading OCL in a code review.
Both of those are going into our modelling standard. The plural/singular convention in particular — we have been inconsistent about that and it does make expressions harder to read.