modeling max function using Activitiy Diagram

2 views
Skip to first unread message

charfi asma

unread,
Jan 25, 2010, 5:32:13 AM1/25/10
to umlf...@googlegroups.com
Hello,

I tried to model this C++ function using AD(we assume that there is an operation named max in class Class0, and the AD will model the behaviour of that operation)

int max (int a, int b)
{
if a < b
return b
else
return a;
}

I tried to use activity parameter nodes with 2 input parameter (int a and int b) et one outpout parameter
I used a desision node like follow

a<b
<> _ _ _ _
|
| a>b
|

but I can not link this decision node neither with the 2 input parameters nor with the result (output parameter)
because:
- I think that decision node has only one incoming flow, so how can I add both a and b to the decision node
- I think I can use a merge node after the decision one, but How can I say that one flow of the outging flows of a decision node holds only the maximum between a and b?

I seems to be very confused :(
did so has an idea how we can model such a simple function ?

thank you very much for your help.

Asma


asma

unread,
Jan 25, 2010, 5:38:36 AM1/25/10
to UML Forum
modeling max function using Activitiy Diagram
...
Lun 25 Janvier 2010, 11 h 32 min 13 s
De :
charfi asma <charf...@yahoo.fr> [Discutez !]
...
Voir le contact
À : umlf...@googlegroups.com
Hello,

I tried to model this C++ function using AD(we assume that there is an
operation named max in class Class0, and the AD will model the
behaviour of that operation)

int max (int a, int b)
{
if a < b
return b
else
return a;
}

I tried to use activity parameter nodes with 2 input parameter (int a
and int b) et one outpout parameter
I used a desision node like follow


a<b
<> _ _ _
|

Livia Pérez

unread,
Jan 25, 2010, 8:07:51 AM1/25/10
to umlf...@googlegroups.com
Sorry, but I can't understand... Where's the UML here?

It seems that you are thinking about C++ code in place to think of UML.


2010/1/25 asma <charf...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "UML Forum" group.
To post to this group, send email to umlf...@googlegroups.com.
To unsubscribe from this group, send email to umlforum+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/umlforum?hl=en.




--
Att,

Lívia Pérez Bettero
55 21 8708-8408

charfi asma

unread,
Jan 25, 2010, 2:31:58 PM1/25/10
to umlf...@googlegroups.com
Hello Péréz,
 
The UML Activity Diagram is used to model behaviour of operations (the code of operations)
here I have an UML class with operation called max that take 2 parameters and has a type of int.
the  C++ code  is the behavior of max operation, I try to model this usin AD and UML actions...
 
Asma


De : Livia Pérez <livia...@gmail.com>
À : umlf...@googlegroups.com
Envoyé le : Lun 25 Janvier 2010, 14 h 07 min 51 s
Objet : Re: [UML Forum] modeling max function using Activitiy Diagram

Michael Jesse Chonoles

unread,
Jan 25, 2010, 8:53:29 PM1/25/10
to umlf...@googlegroups.com
Well, this is particularly silly thing to do ---


there are several ways.

1)
both a and b could go into the same action, which could subtract b from a (result=a-b)
the result could go the decision node, which would test on <=0 or  > 0.

Depending on the result the flow would go to a different action. Each action would have two inputs, one the result from the test and the other the appropriate a or b value, which would then go to the return value.

2)
In the UML 2.2, the decision node has been modified so that it can accept one or two inputs to handle this sort of thing.
Michael

--- On Mon, 1/25/10, asma <charf...@gmail.com> wrote:
--
You received this message because you are subscribed to the Google Groups "UML Forum" group.
To post to this group, send email to umlf...@googlegroups.com.
To unsubscribe from this group, send email to umlforum+unsub...@googlegroups.com.

charfi asma

unread,
Jan 26, 2010, 4:53:28 AM1/26/10
to umlf...@googlegroups.com
Hello Michael,
Think you very much for your answer, but I prefer an AD that map directly to the C++ source code (in my C++ code I have not the instructions: int c= a-b; if (c<0) else ...

1) in your first solution, I do not understand the last sentense: "... which would then go to the return value"
the return value is the out put parameter of the activity, Can I put 2 incomings edges to this output parameter? I thik I could not, so in this case, I have to put a merge node or 2 output parameters. Is this what you have meant ?

2) I red the UML decision node specification, and I find that there is a constraint: all incoming and outgoing edges (expect the decision input flow) must have the same kind of flow (all are objects flow) or (all are control flow).
The outging flows from the decison node are (as I think ) control flows. So I could not add an object flow to the decision node, Am I right ?

thank you again



De : Michael Jesse Chonoles <mjcho...@yahoo.com>
À : umlf...@googlegroups.com
Envoyé le : Mar 26 Janvier 2010, 2 h 53 min 29 s
Objet : Re: [UML Forum] modeling max function using Activitiy Diagram
To unsubscribe from this group, send email to umlforum+u...@googlegroups.com.

asma charfi

unread,
Jan 26, 2010, 7:53:14 AM1/26/10
to umlf...@googlegroups.com
Hello Michael,

Thank you very much for your answer, but I prefer an AD that map directly to the C++ source code (in my C++ code I have not the instructions: int c= a-b; if (c<0) else ...

1) in your first solution, I do not understand the last sentense: "... which would then go to the return value"
the return value is the out put parameter of the activity, Can I put 2 incomings edges to this output parameter? I thik I could not, so in this case, I have to put a merge node or 2 output parameters. Is this what you have meant ?

2) I red the UML decision node specification, and I find that there is a constraint: all incoming and outgoing edges (expect the decision input flow) must have the same kind of flow (all are objects flow) or (all are control flow).
The outging flows from the decison node are (as I think ) control flows. So I could not add an object flow to the decision node, Am I right ?

thank you again

Asma

2010/1/26 Michael Jesse Chonoles <mjcho...@yahoo.com>
To unsubscribe from this group, send email to umlforum+u...@googlegroups.com.

Livia Pérez

unread,
Jan 26, 2010, 10:40:38 AM1/26/10
to umlf...@googlegroups.com
Sorry...
I really cant't understand where's the doubt about this...
 
You need a activity do "input parameters", and another one to "calculate value".
So you need a decision point If the value returned is X, you get a way to a activity X... But if the value returned is Y, you get another way to a activity Y.
Both activities X and Y can go to the same final point or one of them can back to another part of the structure... It depends..
 
There's no mistery.


 
2010/1/25 Michael Jesse Chonoles <mjcho...@yahoo.com>
To unsubscribe from this group, send email to umlforum+u...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/umlforum?hl=en.
Reply all
Reply to author
Forward
0 new messages