It's not a secret anymore!*
The moose likes OO, Patterns, UML and Refactoring and the fly likes can I use fork to present multiple actions within a same method? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "can I use fork to present multiple actions within a same method?" Watch "can I use fork to present multiple actions within a same method?" New topic
Author

can I use fork to present multiple actions within a same method?

kevin ou
Greenhorn

Joined: Feb 15, 2003
Posts: 23
Hi all,

For instance, if I have a method A() and within method A, I will have several methods like A1(),A2()... etc. So my question is, how to present these methods (A1(),A2()) for method A() in the Activity diagram? Should I use fork?
Thanks.

Kevin
Sathya Srinivasan
Ranch Hand

Joined: Jan 29, 2002
Posts: 379
You can use a self-call (looping line) in a sequence diagram to call a method of an object from another method of the same object.


Cheers, Sathya Srinivasan - SCJP 1.2, SCWCD 1.2, SCMAD 1.0
Co-Author of Whizlabs SCMAD Certification Exam Simulator and SCMAD Exam Guide Book
kevin ou
Greenhorn

Joined: Feb 15, 2003
Posts: 23
i need to present it in the Activity Diagram. Moreover, I need to mention that A1() or A2() methods are not concurrent, they are just in sequence.
Sathya Srinivasan
Ranch Hand

Joined: Jan 29, 2002
Posts: 379
Well,

Sequence diagrams do exactly that - mention methods in sequence. Activity diagrams are typically used to display logic within a class (as a part of state transition - some consider it as an alternate view to state diagrams). I have personally used it to show conversation for use cases.

The fork (techically, the decision box) is used like the 'diamond' in a flowchart, which typically represents an if...then...else situation.

From what you say, I don't think that's what you want to represent.
Scott Ambler
author
Ranch Hand

Joined: Dec 12, 2003
Posts: 608
There are several examples of forks presented at http://www.agilemodeling.com/artifacts/activityDiagram.htm .

Simply draw a parallel bar with one arrow entering it and several, one for each line of logic, leaving it. At some other point you should join the logic streams, see http://www.agilemodeling.com/style/activityDiagram.htm for modeling guidelines.

- Scott


<a href="http://www-306.ibm.com/software/rational/bios/ambler.html" target="_blank" rel="nofollow">Scott W. Ambler</a><br />Practice Leader Agile Development, IBM Rational<br /> <br />Now available: <a href="http://www.ambysoft.com/books/refactoringDatabases.html" target="_blank" rel="nofollow">Refactoring Databases: Evolutionary Database Design</a>
kevin ou
Greenhorn

Joined: Feb 15, 2003
Posts: 23
First of all thanks for all the inputs, however as I am concerning, the fork is used to present concurrent threads. In my case, A1(),A2() in method A() are not concurrent. They are all called from A(). So the question is, is it appropriate to use fork for this kind of calling methods?
Scott Ambler
author
Ranch Hand

Joined: Dec 12, 2003
Posts: 608
If they're not concurrent then you shouldn't use forks.

Your next best option is to simply have flows from the invoking activity to the sub-activities. If all activities must end before continuing then have them go into a join.

However, it's beginning to sound as if activity diagrams are not the way to go in this case, that you should consider another diagram (sequence diagrams come to mind).

- Scott
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: can I use fork to present multiple actions within a same method?
 
Similar Threads
Dynamically pass values from one jsp to another
inner class
Garbage Collection
getting a copy of an object
If Java were pass by reference...