list of dots

User Manual    [Previous]   [Next]   

E180 Duplicate Association Name Class Hierarchy

Umple semantic error reported when a subclass has an association that is not a specialization, but where the association has the same name as the superclass association

A subclass can not have an association with the same role name as an association of its superclass, unless it is a valid specialization. A valid specialization would be to the same class, but with a refined multiplicity (see the second example)

Example

class Person {
	* -> * Person friends;
}

class Student {
	isA Person;
	* -> * Dog friends;
}

class Dog {
}
      

Load the above code into UmpleOnline

 

Another Example

// This example shows a valid specialization
// of the friends association in which the
// multiplicity 0..3 is refined to *, so a
// student may have any number of dogs but
// Persons in general are limited to 3.
// This conforms to the Liskov substitution
// principle: The preconditions on Person
// operations such as addDog limiting to 3
// are being relaxed in the subclass Student.

class Person {
	* -> 0..3 Dog friends;
}

class Student {
	isA Person;
	* -> * Dog friends;
}

class Dog {
}
      

Load the above code into UmpleOnline