The amazing adventures of Doug Hughes

UML: Activity Diagrams

In my last major entry on the UML I covered the Use Case diagram. The Use Case diagram is a diagram used to gather requirements and help with analysis. Once you have gathered your Use Case diagrams you can continue on with the analysis phase by using Activity Diagrams.

Activity Diagrams are used to illustrate the activities implicit in a use case. For example, consider this Use Case diagram:

UML Activity Diagrams 1

This Use Case diagram clearly states that Search Users will Search Content. However, it doesn’t make any attempt to say anything about the steps involved. This is where Activity Diagrams come in.

Activity Diagrams are very similar to standard flow charts. The major difference is that activity diagrams allow for parallel processing of tasks. (In the ColdFusion world you really don’t need to worry about this difference.)

Here is an example Activity Diagram illustrating the Get Out of Bed use case:

UML Activity Diagrams 2

This diagram is made up of the following notational elements:


UML Activity Diagrams 3

Activities are used to indicate actions which are preformed in your diagram. In the previous example the activities were: Alarm Goes Off, Hit Snooze, Shut off Alarm and Get Out of Bed. Activities are shaped like pills and have a description inside.


UML Activity Diagrams 4

The lines with open arrow heads are called Transitions. Transitions are used to indicate the process flow between elements in your diagram. In the Get Out of Bed example above, you can see that the Alarm Goes Off activity transitions to the Sleepy state. There are nine transoms total in the example.

Decision Points

UML Activity Diagrams 5

There are two ways to draw logical branching in activity diagrams. The Get Out of Bed example uses a decision point “Still Tired?” If Still Tired? is Yes then the flow transitions to the Hit Snooze activity and then back to the Asleep state. If Still Tired? is No then the flow transitions on to the Shut off Alarm and Get Out of Bed activities.

The text shown in square brackets on transitions out of the decision points is called Guards. For flow to progress through a guarded transition the guard must evaluate to true in the context of the decision point. For example:

UML Activity Diagrams 6

This rather simplified diagram illustrates the decisions involved in buying a car. We can see that if we’ve got less than a $100 we’re going to be stuck in a used Yugo. However, as long as we don’t have too much money we’re going to be able to drive a Sensible Car. And, if we happen to have too much money we’re going to end up with a nice sports car.

Guards need to be mutually exclusive. For instance, it wouldn’t make since in the diagram above to show that if we have more than $100 that we’ll buy a sensible car, because that could overlap with Too Much Money guard and we wouldn’t know what to do.

You don’t need to use decision points to show decisions. You can also simply draw multiple guarded transitions out of an activity. Here’s the car buying diagram again, this time without the transition point:

UML Activity Diagrams 7

In general, the decision to use Decision Points is up to you. (Frankly, no one seems to use the same conventions in UML diagrams anyhow, so you could probably use pink elephants to indicate decision points, so long as you’re consistent!)


UML Activity Diagrams 8

States are represented by rounded rectangles. (Sometimes they are segmented like in the examples above, sometimes they’re not. As far as I can tell, there’s no difference.) States are used to indicate milestones in processing of your activity diagrams.

In the example above there are three states, Asleep, Sleepy and Awake. These indicate the “state” of the person being woken up.

Starting State

UML Activity Diagrams 9

Start States are a special type of state indicating the starting point for your activity diagram. There can be only one start state on your diagram. Starting States are always drawn as a filled circle. Sometimes people draw a descriptive caption underneath the Starting State. In the Get Out of Bed example we could probably have gotten rid of the Asleep state and called the starting state Asleep instead.

Ending State

UML Activity Diagrams 10

Ending States are similar to Starting States; accept that they indicate ending points for processing. The other big difference is that there can be multiple Ending States on your diagram. Ending States are drawn as a filled circle with a ring around it. (It makes me think of Saturn, for some reason.) As with Starting States, sometimes people draw a descriptive caption underneath the Ending State. In the Get Out of Bed example we could probably have gotten rid of the Awake state at the end and called the Ending State Awake instead.

Forks and Joins

Seeing as my audience is primarily ColdFusion programmers, forks and joins probably won’t make much of a difference to you (unless you use ColdFusion MX 7 Enterprise, which now has an asynchronous event gateway). However, for the sake of completeness I will do a brief overview of them.

Forks and Joins are shown as black bars and are used to indicate parallel processing. For an example, look at this diagram:

UML Activity Diagrams 11

This diagram illustrates the process of getting in the shower. The diagram starts with the Turn on Shower event. However, the shower always comes on cold and takes a while to warm up, so, for the sake of efficiency, we will fork out and do more than one thing at a time. In our example, while we Brush our Teeth and Shave we are also busily waiting for the water to get warm and happily wasting precious natural resources. When we’re done with all of that, we will join our processes back together and Get in Shower and proceed to play with the Rubber Ducky.

Forks are always shown as a solid bar with one entry transition and multiple exit transitions.

Joins are always shown as a solid bar with multiple entry transitions and a single exit transition.

Swim Lanes

There is one other big notational element to activity diagrams, Swim Lanes. Swim Lanes are used to illustrate which portions of a system are responsible for particular elements of your diagram. Here’s an example:

UML Activity Diagrams 12

This diagram illustrates a User and a Website. The user is attempting to log on to the website. As you can see, the User is responsible for providing login credentials, while the Website is responsible for authenticating the user.

One thing about swim lanes which confuses me is where elements like Show Error Message or Show Intranet should be placed. I put them in the User column because the User sees it. However, it’s really the website which performs the action of showing, isn’t it? My opinion is that it doesn’t really matter where these are placed. The purpose is to show that the User and the Website work together to Authenticate the User and Show the Intranet.

Note: The diagram above is interesting too because it shows multiple Ending States, one for success and one for failure.

How to Draw Activity Diagrams

The process for creating activity diagrams is pretty simple. You can accomplish it by following these steps:

  1. Identify a Use Case you want to create an Activity Diagram for.
  2. Draw a simple Activity Diagram which shows the primary success scenario from beginning to end. Don’t worry too much about details yet.
  3. Go back and add in alternative paths through the use case, including those which will result in errors.
  4. Add detail to the diagram.

As a note, you might end up with portions of your diagram which are so complex that they warrant an activity diagram. This is part of the point of these diagrams. This level of discovery helps you understand the scope of your software.

Let’s Draw Some Diagrams

In previous entries on UML, I created a requirements document and Use Case diagrams for a searching and indexing API for ColdFusion based on Lucene. I will now use the Use Case Diagrams to create a set of Activity Diagrams.

Search Content

The Search Content Use Case diagram was pretty simple:

UML Activity Diagrams 1

I started diagramming by creating a simple Activity diagram which illustrated the primary success scenario.

UML Activity Diagrams 13

Now that I have the primary success scenario I need to go back and add some detail. For instance, what happens if I don’t provide any criteria or what happens if the index I’m searching doesn’t exist?

UML Activity Diagrams 14

Now that I’ve got a pretty good idea of the flow through the process, I would like to get a better idea of what we’re interacting with. I know I’ve got a Search User and a Search API. I think we could add some swim lanes to help clear this up a bit.

UML Activity Diagrams 15

Index Content

The Index Content Use Case will necessitate a bit more complexity in our next Activity Diagram. Here’s the Use Case diagram:

UML Activity Diagrams 16

I started by modeling the primary success scenario like this:

UML Activity Diagrams 17

This activity diagram does a pretty good job of illustrating the primary success scenario but it does need some more detail. For instance, what happens when the index does not exist? How does the system know where the index is located? What if there are no items in the queue? What if you can’t retrieve the document?

I went ahead and added some detail and some swim lanes to this diagram and this is what I came up with:

UML Activity Diagrams 18

By now, you should be able to read this diagram (and I’m tired of typing) so I’ll leave its interpretation to you.

One thing I’ve decided not to cover in this diagram is exactly what information is being indexed and how the information is being extracted from the document. This could easily warrant another activity diagram. However, I have some complex plans for these so I think I’ll leave the implementation details to another type diagram, perhaps a sequence diagram.

Do you have any comments, criticisms or questions on thisentry? If so, please leave feel free to comment below.

Search Engine API Requirements Version 2

Comments on: "UML: Activity Diagrams" (67)

  1. Sean Corfield said:

    Nice examples! (Well, you complained that I didn’t comment on your other UML stuff)


  2. Doug Hughes said:

    I’ll have everyone know I didn’t complain. I meerly asked if he had read them and, if so, if he had any criticisms! After all, he is Mr. UML.

    Besides, I can’t get anyone else to comment!


  3. No comment.


  4. Erki Esken said:

    Just wanted to thank you for posting these UML articles. I’ve recommended our junior developers to read these too.

    Also, please check your UML category articles, there are two articles in UML category that don’t belong there. If you can remove those from that category.


  5. Doug Hughes said:


    You’re welcome! It’s been a lot harder to write these than I anticipated, but it’s been well worth the effort. UML is an interesting tool.

    The only advice I can give your junior programmers is to not get too wrapped up in the "correct" way to use UML. I havn’t found any consistancy in how they’re applied (or even in the notation!!) in any of the books I’ve read. Just try to be consistent in how you express your ideas.

    If you (or anyone) have any feedback, questions, criticisms or anything else, please feel free to let me know.

    Thanks for the encouragement.


  6. Doug,

    I am trying to use a UML tool to map out a large coldfusion application for myself and 4 other developers who are working on the project. I have seen a few, but they all seem a little difficult to use. Which tool would you recommend for a CF developer?


  7. Do you know any tool (c++ or java) to graphically represent acitivty diagrams thanks to a provided API ?


  8. do u have the activity diagram about manufacturing car?thanks


  9. Your comment about consistent modelling is quite interesting. I have watched UML and other software modelling paradigms for many years and UML has always seemed “loose” in IMHO. My expertise is in IDEF0/SADT modelling – something small in symbol set, but very rigid in style. I’m not interested in the “code from drawings” goal, but there has to be some rules that force you, for example, to create a class diagram for objects you depict in other diagrams. It would be nice to see documentation about relationships between UML elements in diferent diagrams.


  10. this was a one shot good explanation about activity diagrams, I enjoyed reading this and it helped me at the most. thank you Doug Hughes


  11. Sridhar Visvanath said:

    Wow Wow Wow! The best set of examples and awesome explanation and walk through.

    This is the best article I have read on Activity diagrams.


  12. Awesome. This is the kind of explaination, i was looking for better understanding of activity diagram.


  13. Good article!
    I have noticed some Use Cases are in your Activity Diagram, for instance, “Delete from index”. After all, what are the differences between a Use Case and an Activity? My answer is the low level use cases are same as activities.
    What would you think?
    Thanks a lot.

    Haibo Hu


  14. Yogesh Puranik said:

    Nice and Helpful Article.

    I am more interested in Swim Lane diagram. Could you please let me know hoe to draw these diagrams i mean..using which tool?

    It would be very useful for me if you could provide me the details related to swim lane diagrams like
    1) what is swim lane diagram
    2) its usage
    3) Tools to draw the diagram.



  15. Finally some serious examples. Was tired of browsing web. Excellent work ! Put more if you find something interesting real-life examples. Although, I liked also waking up example to show core. Really good !!!


  16. sfasdf


  17. asdfasdf


  18. Hi to all. I need sequence diagram for shopping cart (search, add product, update and delete product, cart, purchase)


  19. Tribhuwan Bisht said:

    Its a Very good Article covering most of the aspects with good example which otherwise make designer life difficult.

    – Trib
    Sr. Architect.
    KPIT /DFS.


  20. does any body told me

    plz i need urgently


  21. I need to throw exception: create an exception object and throw it.

    Of course that has to be done in the sequence diagram.

    I don’t know how to model this, can you help with this….



  22. Hi to all. I need sequence diagram for shopping cart (search, add product, update and delete product, cart, purchase)


  23. does any body told me

    Well, you should create a collaboration diagram where you link use case with sequence diagrams. This way you do the traceability.

    Perhaps there are other solutions as well, such as put them in the same package, etc.


  24. Nice and helpful diagrams. iam interesred to learn more from this site. kindly help me to learn more.Daisy


  25. it extremely useful diagrams.let me know more.


  26. Not Good information which can be use for ………….


  27. Thnaks for the help.A good tool is Visual Paradigm for UML..


  28. thanks


  29. Hi Master.
    Please Send ME A Simple Project In Unified Moddeling Language
    I need a Beauty Project
    I have Not Enough Time


  30. plse help me in drawing dioagrams of search engine.


  31. i need stock maintenance system use case diagram


  32. please help me in use case diagram for library maintenance system


  33. This is a good arcticle on how to use class and activity diagram.


  34. please help me class diagram for online book shopping


  35. jyssa may bermudez said:

    plz,a diagram sample for success!!! plz lang po…………..assingment lang namin!!!


  36. please help me to draw UML diagrams for online shopping


  37. Good material

    Thank u


  38. please show me how the intranet Activity diagrams look like


  39. Gopi Chand said:

    Hai This Article helped me alot

    But can i know that

    does an activity diagram can end without end state or an activity.

    i want to know that can we end an activity diagram by using a simple transition.


  40. manju eeeeeee diagrams amina use avtaya


  41. hello,can u plz help me in drawing the activity diagram for maintenance where the jobs are manage running jobs,manage schedules,manage roles,maintain system-wide role applications


  42. i need how to draw uml diagrams


  43. i need how to draw uml diagrams

    Posted By: paveen on Apr 6, 2009

    In order to draw UML diagrams u need some tools.

    For example to draw diagrams there are some tools

    1)Visual Paradigm
    2)Rational Rose
    3)MyEclipse Plugin in eclipse IDE



  44. Jun Roxas said:

    Microsoft Visio 2007 has a built in UML 2 activity diagram template


  45. arunkumar said:

    it is really nice.. thanx


  46. dipesh patel said:

    I want to draw UML diagram for online wedding shopping. Iam unable to draw it. Could u help me????


  47. This was a very useful reads for me. Thank you for putting the information across in such an easy to understand way.
    Will follow this blog with interest.


  48. images are not available


  49. all uml diagrams for search engine


  50. prathyusha said:

    problem statement in uml for search engine


  51. all uml diagrams for resource management for project


  52. hiee can u provide me the activity diagrams for college website management system


  53. i want to draw uml diagrams for online library management system.could u help me?


  54. See for a dynamic reverse engineering application which generates UML Sequence diagram and view of Participating Class diagram from any Java Application at runtime
    All you have to do is just run your application and sit back. Reverse Java runs in background tracing all the activities happening inside your application and creates UML diagram for you.


  55. hello sir
    please send this webside uml diagram


  56. sonal chaudhary said:

    i want to draw uml diagram for webside help me


  57. thanx for the information.could you please provide me activity diagram for intranet mailing system


  58. plz can u help me out with all the uml diagrams for a email system


  59. please provide me with uml diagrams for the search engine i couldnt find them pls help urgent for project submission pls


  60. Hi,

    Nice article. Unfortunately for some reason I could’t view the images. Tried to run it both, firefox and IE. It’s the same for your other two articles on use case diagram. Shame, they’re very good read, would be even more helpful with the diagram. Am I the only one having this problem?


  61. hi plz send me the sequence diagram for “timetable”


  62. hy plz send me activity diagrams send this mail id


  63. Where did all the images go?
    Can I be sent them by any chance?


  64. Hello man, Your articles are so special, i bookmark yours website to visit any weak thanks man for this kind of information! Bejhoo Kedodoran


  65. This blog provide nice information, keep up the good work.


  66. plz send activity diagram for virus infomation system


Comments are closed.

Tag Cloud

%d bloggers like this: