3

Given an object array, an instance of some arbitrary class Array, which for this purpose has an attribute length.

How can I model an UML activity diagram, that, at some point, uses array.length in an control flow statement, i.e. in guards of a decision node.

array = getArray();
if (array.length > 5)
    save();
else
    waitForData();

I know that the guards of the used decision node would be [array.length > 5] and [array.length <= 5]. But I am not sure how I can integrate this with the object flow present in activity diagrams.

1 Answer 1

2

UML does not specify how the guards should be described. It only requires it to be a logical expression i.e. one that evaluates either to true our to false. You can use a natural language, any programming language or OCL. The statement you've used is absolutely valid. Additionally you can put a status of an object on an object node, e.g. [length > 5]

Sign up to request clarification or add additional context in comments.

2 Comments

I also just read that natural language contracts are perfectly acceptable in UML.
@mike the purpose of OCL / precise languages is that they are machine-consumable and don't introduce ambiguity. If your target audience is humans, then natural language can be good enough.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.