Finding Behavior¡ Class and object diagrams provide a static view of the system we are modeling¡ In many cases, this is not sufficient for us to truly understand how classes interact or how the system must respond to varied run-time states¡ Therefore, UML introduces 4 types of dynamic diagrams: Sequence diagrams, Collaboration diagrams, State diagrams and Activity diagrams, collectively known as Behavioral diagrams
Sequence diagrams modelthe flow of use casescenarios¡ Show how objects interact with one another
Sequence diagramsemphasize objectsinteraction over time¡ Objects ¡ What classes we need to write ¡ Which actors need to be involved ¡ What responsibilities need to be written¡ Interaction ¡ Coupling ¡ Shows where we can reduce coupling by moving responsibilities¡ Over time ¡ The order of events ¡ Exposes where efficiency can be gained by synchronous operations
How do I create asequence Diagram?1. Pick a scenario that you want to model2. Try to identify the objects that will be involved in the scenario3. Line them across the top in the approximate order that theyre (listed in the order that they are used for the scenario)4. Draw dotted lines down indicating lifelines5. Identify the first event (triggering event)6. Draw a horizontal arrow from the object that sends a message to the object that receives it7. identify the next event and the objects involved8. Redo steps 6 and 7 until the diagram is complete
Sequence Diagrams¡ Example Sequence Diagram (fast food order) :DriveThruAttdt :FryMaker :BurgerMaker Order Value Meal Place Fry Order Place Burger Order :Customer Fill Drink Assemble Order
Activation bars can showwhen that object is awake
Sequence Diagram withactivation lines :DriveThruAttdt :FryMaker :BurgerMaker Order Value Meal Place Fry Order Place Burger Order :Customer Fill Drink Assemble Order
We can show the lifespan ofan object¡ The object names can be lowered from along the top to indicate when they are created during the sequence¡ We can put an X on the lifeline to show when an object is no longer needed
Sequence Diagrams withlifespan added :DriveThruAttdt :FryMaker Order Value Meal Place Fry Order :BurgerMaker Place Burger Order :Customer Fill Drink X X Assemble Order X
Conclusion¡ UML sequence diagrams help you to envision what will happen during the execution of a use case¡ They are great to help developers and business analysts get to a common understanding
A particular slide catching your eye?
Clipping is a handy way to collect important slides you want to go back to later.