Sparx Systems Forum
Enterprise Architect => Uml Process => Topic started by: Roggan on December 12, 2004, 03:56:02 am
-
Hi,
Im new to UML and having some trouble understanding activities together with swimlanes.
assume the following scenario.
Dice game:
game class
player class
dice class
lamp class
each game has instances of 1 player , 2 dices and 2 lamps (red and green)
game lets player throw dices ,
game calculates sum of dice1 and dice2
if sum = 7 turn green lamp on
else turn red lamp on
end
how would that be modelled in an activity diagram ?
(with swimlanes and object states)
i read in an uml book the other day that by looking on which activities goes in which swimlane , i could create my components interfaces from that.
but i dont see how this would apply here.
so if anyone have the time , please enlighten me :)
//Roger
-
A swimlane shows which class, person etc. is responsible for the event in the activity diagram.
In your case, you should have a swimlane for each class. Then for each action in the activity diagram, indicate which class manages or performs the action.
So throwing the dice is in the player swimlane, the generation of the numbers in the dice swimlane, the total calculated by the game, etc.
-
Roggan,
additionaly to Kevins statement it has to be mentioned that activity diagrams are usually used as e.g. sub-diagrams for use cases. Here you can graphically show how a certain scenario is executed. In your example you have an actor Player and a use case Play Game. There under you will start (filled bullet) and target your first activity ("throw dice"). Depending on the result you could then fork and go on with the scenario.
You'll notice that activity diagrams are rather independent of your later class model. The balancing act between these is really difficult to explain in few word. You should search the forum for "activity" and/or "use case" to find out more.