UML Diagrams Zicomi Systems publishes some UML example diagrams online from the world famous UML dictionary. more...
Version 2.5 Released Zicomi Systems is delighted to announce that version 2.5 of Zicomi Mentor is released. With support for UML 2.0 and all thirteen UML diagrams more...
Zicomi Systems' Director speaks about the UML at Objects by Design - an informative interview more...
Partner Programme Zicom Systems is delighted to announce a new world wide partner programme, become a partner today. more...
OMG Member Zicom Systems is made a member of the OMG!
Bag
A value of bag specified for the property string of an association end indicates that the same instance can appear more than once in the collection. By default an association end is a set of instances, meaning that there cannot be duplicate elements. By setting the value to bag this default behavior is overridden and duplicates can occur.
Explanation
A bag is a collection that can contain the same element any number of times. An association end relates an instance at one end to a number (collection) of instances at the other. The default value for this property is ?set? which adopts its mathematical meaning that elements can only appear once. Specifying ?bag? for this property overrides this value and allows an instance to appear any number of times. In our daily lives we see examples of this distinction, for example if a competition has three prizes: first, second and third, an association could be used to model the relationship between the competitors and prizes. Specifying the property string of ?bag? at the prize end of the relationship would allow a given person to win more than one prize. The normal or default rule for competitions is often that once a person has won a prize they are not eligible for other prizes; this would be modeled by not specifying the property, implying the default value of ?set?.