bbuser
bbuser

Reputation: 928

Can this relationship be modelled in UML?

I have received the following UML diagram for implementation:

enter image description here

From the problem description I know that

Is this what the UML diagram expresses and if not, how can the described relationship be expressed in UML?

In other words: the relationship between Foo and Bar can only exist if both belong to the same Block. I have been told that the aggregation (diamond) in the diagram ensures that this is true.

I've asked another question about the same problem.

Upvotes: 0

Views: 70

Answers (3)

vadim
vadim

Reputation: 11

http://www.omg.org/spec/UML/2.5/Beta1/PDF/ page 194 (in file 204), Figure 11.5

Upvotes: 1

gefei
gefei

Reputation: 19856

Your diagram is OK. In order to express the requirement that the Foos of a bar must be in the same Block of the Bar, you need what is called a constraint. In UML, constraints are usually formulated in the Object Constraint Language (OCL).

Your constraint may be written like this:

context Bar
inv: self.foo -> forAll(t |  t.block = self.block)

Upvotes: 2

Related Questions