Use Case Modelling: Activity and Sequence Diagrams
Overview of Use Case Modelling
Behavioral modeling in Universal Modeling Language (UML) describes how a system functions over time. This involves detailing user actions, data flow, and the passing of messages between various parts of a system. Key techniques for modeling use case behavior include:
Fully developed Use Case descriptions.
Activity Diagrams.
System Sequence Diagrams (SSD).
Models and Modeling
A model is a representation of a specific aspect of a system being built. Models can be categorized into three types:
Textual models.
Graphical models.
Mathematical models.
Modeling provides several critical benefits to the development process:
Reducing Complexity: Achieved through abstraction, focusing on specific elements at a time.
Communication: Facilitates dialogue among development team members, users, and diverse stakeholders.
Documentation: Records the system's design for future maintenance or enhancement projects.
Information Retention: Helps the development team remember all specific details throughout the project lifecycle.
Fully Developed Use Case Descriptions
While a brief description is sufficient for very simple use cases in small, well-understood applications, complex use cases require fully developed descriptions. These descriptions follow a specific template consisting of eleven key terms:
Use Case Name: A unique and descriptive name for the use case.
Scenario (if needed): The specific instance of the use case being documented.
Triggering Event: The specific business event that initiates or triggers the use case.
Brief Description: A one or two-sentence summary of the results produced by the use case.
Actors: All actors who interact with this specific use case.
Related Use Case: Any included use cases or use cases that "include" this specific one.
Stakeholders: Individuals other than the actors who have an interest in the successful completion or results of the use case.
Precondition: The state of the system before the use case begins, with particular emphasis on required database conditions.
Postcondition: The state of the system upon successful completion, specifically detailing updates or changes to the database.
Flow of Activities: A step-by-step sequence of actions performed by both the actor and the system's internal processes.
Exception Conditions: Conditions that cause the system to deviate from the expected flow of activities or cause the use case to terminate abnormally.
Activity Diagrams
An activity diagram is a model used to describe the internal processing of a use case. It details the specific activities, the individuals (persons) responsible for each activity, and the sequential flow of those activities.
Activity Diagram Notation
Swimlane Heading: Identifies the person or organizational department responsible for the activities within that lane.
Starting Activity (Pseudo): Indicated by a solid black circle, marking the beginning of the flow.
Ending Activity (Pseudo): Indicated by a bullseye icon (a circle containing a smaller solid circle), marking the termination of the flow.
Activity: Represented by a rounded rectangle containing the name of the task (e.g., "Prepare report").
Transition Arrow: Shows the direction of the flow between activities.
Synchronization Bar (Split): A horizontal or vertical solid bar where one transition splits into multiple concurrent paths.
Synchronization Bar (Join): A horizontal or vertical solid bar where multiple concurrent paths converge into a single transition.
Decision Diamond: A diamond shape used to show branching paths based on specific conditions, usually labeled with "yes" or "no". Decisions can also be shown without the diamond by labeling multiple outgoing transition arrows from an activity.
Examples of Activity Flow
Concurrent Paths: Used when tasks like "Buy materials" (Purchasing) and "Program computer" (Production) happen simultaneously before a final "Schedule production" task.
Include Relationships: An activity diagram for a "Fill shopping cart" use case may include other subordinate use cases.
Loops: Activity diagrams can represent repetitive processes by looping transition arrows back to a previous activity until a condition is met.
System Sequence Diagrams (SSD)
A System Sequence Diagram (SSD) illustrates the sequence of messages exchanged between an external actor and the system during a specific use case or scenario. Unlike a full sequence diagram, an SSD treats the entire system as a single object.
SSD Components
Actor: The external entity initiating the interaction.
:System: Refers to the complete system treated as one object.
Object Lifeline: Represented by vertical dashed lines extending down from the Actor and the System.
Messages: Horizontal arrows representing the input and output requirements.
Steps for Developing an SSD
Identify Input Messages: Locate transition arrows that cross the system boundary (typically derived from an activity diagram).
Describe the Message: Use message notation in a verb-noun format (e.g.,
makeDeposit). Determine what the system is being asked to do and what parameters it requires.Add Special Conditions: Include iterations (looping) and true/false conditions.
Identify Outputs: Add return values from each message. These can be shown on the message itself using the assignment operator
or as an explicit return on a separate dashed line.
SSD Notation and Syntax
The standard syntax for an SSD message is:
Asterisk (*): Indicates a repeating or looping message.
Brackets [ ]: Indicate a condition. If the condition is true, the message is sent; if false, it is not.
Message-name: The verb-noun description of the requested service.
Parameter-list: The data passed with the message, enclosed in parentheses for initiating messages and without parentheses for return messages.
Return-value: Data returned from the system to the actor. If using the same line as the message, it requires
(e.g., `).
SSD Frames
For complex flows, frames (labeled rectangles) enclose specific messages:
Loop Frame: Encloses a repeating set of messages.
Opt (Optional) Frame: Enclosed messages are only executed if a condition is met.
Alt (Alternative) Frame: Represents an if-then-else structure where one of several alternative logic paths is taken.
Case Study: UniLife Event Registration Sub-system
This scenario involves a system where students can search for events, register, and cancel registrations. Administrator actors (Club officers) can manage events (create/update) and view registrations.
Learning objectives for this study include:
Drawing a Use Case diagram for the registration scenario.
Drawing an Activity Diagram to show the step-by-step logic.
Drawing a System Sequence Diagram to model the interaction between the student/administrator and the system.
Tutorial Task: The WizardHub Project
The WizardHub project requires process models for key business processes within the Ministry of Magic. For each of the following scenarios, developers must create a Fully Developed Use Case Description, an Activity Diagram, and a System Sequence Diagram, as well as suggest process improvements.
Scenario A: Apparition Licence Application: Citizens must obtain a valid licence from the Department of Magical Transportation to use Apparition.
Scenario B: Magical Artifact Permit Application: Specific magical artifacts require Ministry approval prior to ownership or use.
Constraints for modeling:
Extra interactions or actors may be considered but must be justified.
All assumptions made during the modeling process must be explicitly stated and justified.