language-lawyerumlocl

UML Generalization::isSubstitutable()


On page 180 of the UML 2.5.1 specification under section 9.9.7.4 "Attributes" for Generalization, the default for the Boolean return value doesn't make any sense to me if a null Boolean can be returned. Here is the description:

isSubstitutable : Boolean [0..1] = true

Indicates whether the specific Classifier can be used wherever the general Classifier can be used. If true, the
execution traces of the specific Classifier shall be a superset of the execution traces of the general Classifier. If
false, there is no such constraint on execution traces. If unset, the modeler has not stated whether there is such
a constraint or not.

Default values are meant to be used if there is no other value given; however, this is already the case if a null Boolean value is returned, indicating that "the modeler has not specified whether there is such a constraint or not." Clients querying this attribute would never see the null Boolean if a default is returned and thus could not determine the intent, or lack of it, on the modeler's part, so why the extra default value?

I would think that the declaration of this attribute should either be without any default value, or with multiplicity 1..1 and some default value ... whether or not true makes more sense here than false is also debatable. If it were up to me, I would leave off the default value entirely and just set the multiplicity to 1..1.

Would be nice if someone could explain this to me?


Solution

  • About the default value:

    I think true is a good default value, given the concept of generalization. Normally, if an instance of X plays a role in some algorithm, then an instance of Y, where X is a generalization of Y, can also play a role in that algorithm. For example, if I have a webshop selling bicycles, where Bicycle is a generalization of MountainBike, TouringBike etc, then the sales process for Bicycle also applies to MountainBike and TouringBike.

    In other cases, the modeler may wish to set it to false. For example, if I have class Polygon with method AddVertex(), then the generalization of classes Triangle and Square are not substitutable.

    About the multiplicity:

    I think [0..1] is a good multiplicity. True means substitutable, false means not substitutable, unset means substitutability not guaranteed. If the multipliticy were [1..1], the modeler would not have the option to indicate the latter. For example, the modeler may not have enough information to decide whether all functionality offered for Bicycle also applies to the newly introduced SuperBike.

    About the combination of a default value and multiplicity [0..1]:

    This is perfectly allright. The default value is the value you most probably want and the multiplicity [0..1] gives you the option to clear the value.

    You may disagree with the above and you may wish to discuss improving the UML specs, but that's not something StackOverflow is for.