Responding to azzam...
>
> UML offers several constraints, such as multiplicity constraints,
> generalization set constraints, subsetting, and redefinitions.
> Recently I began to wonder about the importance of these constraints
> in real models (besides DATA BASE world). Actually, I was surprised
> that most examples I found were missing significant constraints.
Well, they should -- provided the constraints exist in the problem
space. Remember that UML models abstract some reality and not all
realities are constrained the same way. However,...
> For example, if we look at the multiplicity constraints, we see that
> the only multiplicity constraints are 0-1, 0-*. I did not find a real
> model which included min-max (*1 < min <= max * *≠** **) in one of its
> association. Am I wrong?
First, let me point out that 0- refers to conditionality, not
multiplicity. That is, it defines whether the association can be
uninstantiated for a particular object at some moment in time during its
existence in the execution session. That is very important to software
at OOP time because conditional associations require checking whether
the relationship is actually instantiated prior to navigating it. [FWIW,
I think UML made a mistake in combining conditionality and multiplicity
in a single notation. It gets confusing when one deals with defaults.]
Also let me point out that UML also supports cardinality (i.e., fixed
numeric values for '*'). Thus a specification of 1..14 means that at
least one but no more than 14 objects can participate on that end of the
association. As it happens, in an OOA/D context one does not care about
cardinality because that is really an issue for tactical resolution of
nonfunctional requirements at OOP time. That is, it affects things like
the optimal choice of collection class for the relationship. [As it
happens, the MDA profile I use for OOA models does not include
cardinality; one relies on an MDA Marking Model to provide that sort of
specification. But I'm a translationist. B-)]
> Does anyone know of models that contain such constraints? Or maybe
> areas where such constraints are significant?
There is no way to specify a multiplicity constraint like 22 < N < 120.
That's because the conditionality and multiplicity constraints reflect
relational theory, as described above. Essentially one is just
specifying 0, 1, or many. However, one can employ more detailed
constraints using OCL tags on the association.
> In addition to this question, I would like to know if these
> constraints can be translated into code. This too is a problem which
> has not really been addressed.
Conditionality and multiplicity should be explicitly defined on all
Class Diagram associations because they are critical to the underlying
relational model from set theory. (OOA/D Class Diagrams are normalized
very much like Data Model ERDs.) In relational theory when a
relationship is limited to exactly 1 participant, that is quite special
and it is known as a 'functional relationship' (for reasons I never
figured out). Thus all one really needs to know is whether there can be
more than one participant. That relational difference is manifested in
OOP implementation by the fact that one always has to implement a *
association with a collection of some sort, while an association limited
to 1 can be implemented more simply (e.g., a pointer). But once one has
to implement with a collection, the actual number of participants only
affects how one optimizes the collection implementation.
As for the general question, the UML constraints are routinely
translated into code by full code generators working from OOA models.
The technology to do that has been around since the early '80s for the
translation methodologies.
>
> This is the same question concerning other constraints: disjoint in
> generalization set, redefinition, subsetting and qualifier.
I don't see a mapping here to a 1 < min < N < max constraint. For
example, in OOA/D all generalization siblings must contain disjoint
member sets and the union of their member sets must be an identity set
to the member set of their immediate superclass. But that is a pure OO
methodological constraint and would not necessarily apply to other types
of modeling (e.g., Data or Domain Models). Thus UML provides explicit
qualifiers like <<disjoint>>, though many OOA/D modelers don't bother
with it because it applies to all their generalizations.
I am not sure I know what you mean by 'redefinition' (overrides in
implementation inheritance?) and 'qualifier' (<<disjoint>>?) here. For
either assumption I don't see a 1 < min < N < max constraint.
--
Life is the only flaw in an otherwise perfect nonexistence
-- Schopenhauer
H. S. Lahman
H.la...@verizon.net
software blog:
http://pathfinderpeople.blogs.com/hslahman/index.html