Book a Demo

Author Topic: Activity diagram - conditional node  (Read 14104 times)

fbvb

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Activity diagram - conditional node
« on: August 05, 2015, 04:50:51 am »
I need to use the conditional node activity diagram. However, I did not find an example of how to do a simple if-else with this component.


qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Activity diagram - conditional node
« Reply #1 on: August 05, 2015, 07:48:08 am »
Either use the Decision element or simply use a guard with the transitions.

q.

fbvb

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: Activity diagram - conditional node
« Reply #2 on: August 05, 2015, 07:52:36 am »
In this example (http://www.inf.ufsc.br/~fabiane.benitti/example.png) there are 2 if, at first I used the conditional node. In the second, as I do? Because for each "test" there is only one "body".

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Activity diagram - conditional node
« Reply #3 on: August 05, 2015, 08:06:02 am »
That's nonsense. It mixes fragments for sequence diagrams in an activity diagram. You "can" do that, but as said it is nonsense. If you leave it completely away you see the decision and the guards. That's "IF" enough.

q.
« Last Edit: August 05, 2015, 08:12:25 am by qwerty »

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Activity diagram - conditional node
« Reply #4 on: August 05, 2015, 09:37:55 am »
WARNING - This is outside of the scope of my personal usage. The following is based on a reasonable ability to read and understand the UML specification and knowledge of EA.

qwerty - This is at least mostly a valid activity diagram. I'll go into the mostly below.

In your example, the conditional node may as well not exist. (The decision is what is driving it, not the conditional node)

The UML specification clearly defines a conditional node as a collection of ordered clauses. (test+body) So an if-else needs to be one clause with a condition, and a second (successorClause) where the condition is always true.

In fact UML states that:
Quote
An “else” Clause is a Clause that is a successor to all other clauses in the ConditionalNode and whose test section always results in true. The body section for such a Clause will be enabled if and only if no other body section in the ConditionalNode is enabled. This ensures that at least one body will always be executed for the ConditionalNode.

Alterations to your model that I would make for (my interpretation of) conformance) are:
  • Move the target for the control flow from your message directly to the conditional node.
  • Move the control flow from your decision to a new initial node inside the body (removing the guard)
  • Change the decision node into an action placing the value of NOT(actual position = next position) onto an output pin.
  • In the properties of the conditional node, set that output pin as the "decider" of the first clause
  • In the properties of the conditional node, create a second clause
  • Add an action out an output pin with the value true for the second test.
  • I assume you then want to specify an else body in the second body section.
It's also possible to have a control flow directly from the outside into a body. My interpretation of that would be that the test (and any tests on predecessorClauses) would then act as a guard on that flow.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Activity diagram - conditional node
« Reply #5 on: August 05, 2015, 07:19:28 pm »
Well, UML 2.5 describes Fragments within Interactions (communication/sequence). Activity diagrams already have sufficient syntax to show algorithmic constructs like if and loop. So a fragment in an activity diagram is simply nonsense.

q.
« Last Edit: August 05, 2015, 07:22:49 pm by qwerty »

fbvb

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: Activity diagram - conditional node
« Reply #6 on: August 06, 2015, 04:10:35 am »
Thank you Simon.

I was able to make some changes you proposed. But the item 3 does not appear the option to select int the "decider". And the last two items I did not understand the proposal - the second clause is for the "else" the conditional node or whether it is to create the second test (NOT encerrada / encerrada).

I've never used this structure (conditional node) and I am trying to understand how it works.

I made available the .eap file http://inf.ufsc.br/~fabiane.benitti/activityDiagram.eap

thanks

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Activity diagram - conditional node
« Reply #7 on: August 06, 2015, 12:01:02 pm »
qwerty - Nonsense because you disagree with the creators of UML that it should be part of the Activity specification, or nonsense because you don't understand it?

fbvb - Not sure what's wrong with selecting the decider. Possibly a bug. Given that there's only one action pin in that block, it can't really be anything else. If there were multiples I would probably use color or thick lines to highlight the relevant one.

Add an action out an output pin with the value true for the second test.
Literally put the value "true". Given you've used the convention of using the expression as the name for the action pin, I would name the decider in the second test as true. This makes it an "else" rather than an "else if".
(Edit - A strict UML way to do this would be to place a ValueSpecificationAction. This allows an instance value or expression to be assigned directly to the result pin. Unfortunately, there's no notation defined by UML or Enterprise Architect to display the expression on the diagram. So I'd probably end up duplicating the expression in the name field anyway.)

I assume you then want to specify an else body in the second body section.
You said you wanted an if-else block. So filling the body with a different set of actions would be equivalent to writing code in that block.
« Last Edit: August 06, 2015, 01:11:17 pm by simonm »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Activity diagram - conditional node
« Reply #8 on: August 06, 2015, 05:47:00 pm »
Simon, it's nonsense because its redundant (and to a very low fraction because it's not with the specs). The "if" is already expressed with the Decision node and the guards.

q.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Activity diagram - conditional node
« Reply #9 on: August 07, 2015, 09:30:22 am »
Quote
Simon, it's nonsense because its redundant (and to a very low fraction because it's not with the specs). The "if" is already expressed with the Decision node and the guards.
Yes, I said that it was redundant on the initial diagram. My personal opinion is that in the simple case it's also much harder to read than a decision node with guards. But I can also see that once you have more than a couple of clauses (conditions) using this notation would be easier to read.

Maybe it would be more helpful to read UML 2.5 section 16.11 before categorizing the whole thing as nonsense.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Activity diagram - conditional node
« Reply #10 on: August 07, 2015, 05:56:56 pm »
You are right. This is a new concept in 2.5. Though it seems like bundling several actions in a so-called StructuredActivity looks like a good concept, I don't think that it is one indeed. Discussing that is likely off-topic. So the only thing I can say: it's compliant but I would not use it. I'm out here.

q.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Activity diagram - conditional node
« Reply #11 on: August 10, 2015, 08:42:15 am »
Quote
You are right. This is a new concept in 2.5.
Not that it matters, but it was pretty much the same in UML 2.0. (Replacing ConditionalAction in UML 1.5)

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Activity diagram - conditional node
« Reply #12 on: August 10, 2015, 07:15:08 pm »
Which tells us that UML still has elements which are conceptually wrong or at least very strange. What is the reason that EA does not have the StructuralActivity metatype?

q.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Activity diagram - conditional node
« Reply #13 on: August 11, 2015, 08:29:53 am »
It does. Drop 'Structured Activity' from the toolbox.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Activity diagram - conditional node
« Reply #14 on: August 11, 2015, 09:44:43 am »
Which proofs: you don't see things you don't want to see :-[
Pretty sure it hasn't been there in former version, though. Somewhere before 9.3 ...

q.