Static and Dynamic Modeling Using UML REQENG
Requirements Engineering Activity Model Requirements Management Requirements Elicitation Requirements Analysis Requirements Specification Requirements Validation Validated Requirements Specification Existing System Information Stakeholder Needs Organizational Standards Technical Standards Regulations Domain Information Goals
Requirements Analysis The process of analyzing requirements to: Detect and resolve requirements problems Decompose (elaborate) requirements Discover system boundary and how system must interact with its environment Discover interactions and overlaps between requirements Gain a better understanding of the problem Includes the following main activities: Requirements classification Conceptual modeling Requirements negotiation Quality of analysis directly affects product quality More rigorous analysis leads to better software quality
Subtopics Class diagram Object diagram Activity diagram Statechart diagram
Class Diagram (As Part of Conceptual Modeling) Used to create a domain model Aids in understanding of domain and requirements Depicts the types of objects in the problem domain Depicts static relationships between objects Depicts the attributes and operations of a class
Classes and Objects Class Object UML Notation Examples Real world entity type about which information is stored Represents a collection of objects with the same characteristics Person, account, employee, car, customer Object Real world entity A single “thing” John John’s account An instance of a class UML Notation Examples
Attributes UML Notation Attribute Example of Attributes Characteristic held by an object in a class Logical data value of an object Example of Attributes account number, balance Each object instance has specific value of attribute John’s account number is 1234 Mary’s account number is 5678 Attribute name is unique within class Example data types include Boolean, date, string, integer, real, time, and currency Examples
Operations Function or process that an object of a class knows to carry out All objects in class have same operations Used to query or manipulate values of attributes maintained by object Correspond to methods Operation is something that is invoked on an object (procedure call) while a method is the body of the procedure UML Notation Examples
Associations Static, structural relationship between classes E.g, Employee works in Dept. Usually read left-to-right and top-to-bottom Inherently bi-directional Name of association is forward direction E.g, Employee works in Department Opposite direction Department has Employee Multiplicity of Associations Specifies how many instances of one class may relate to a single instance of another class UML Notation Example
Multiplicity of Associations 1-to-1 association Company has President 1-to-many association Bank manages Account Numerically specified Car has 2,4 Door Optional association (0 or 1) Customer owns Debit Card Optional association (0, 1, or many) Customer owns Credit Card Many-to-Many association Course has Student Student attends Course
Association Class Class to model association between two or more classes Allow you to add attributes and operations to associations Commonly used in conjunction with many-to-many associations E.g., Many-to-many association between Project and Employee classes Project has Employee Employee works on project Association Class - Hours Attribute - Hours Worked Not an attribute of Employee or Project Attribute of association UML Notation Example
Generalization Relationship (Association) IS A relationship between subclass and superclass Subclass (child) IS A Superclass (parent) Golfer IS AN Athlete Captures commonalties and distinctions among like classes Common attributes, operations, and associations captured by superclass Subclass inherits from superclass Distinct attributes, operations, and associations captured by subclass Subclass is fully consistent with superclass and contains more information Type of association UML Notation Example
Aggregation Relationship (Association) IS PART OF Relationship Also referred to as Whole/Part Relationship Class B IS PART OF Class A Class C IS PART OF Class A Class A is composed of Class B and Class C Arm IS PART OF human body Leg IS PART OF human body Human body is composed of arms, legs, ... Used to show components of a more complex class Distinction between composition and aggregation not real relevant to requirements Type of association UML Notation Example
Constraint Rules Example - a company may have only one CEO Constraints specify conditions or restrictions that must be true Associations, attributes, and generalization specify important constraints UML allows other constraints to be depicted on class diagrams within “{}” Example - an account may not have a negative balance {balance 0}
Benefits of Using Class Diagrams During Requirements Analysis Aids in understanding problem domain and domain vocabulary Surfaces constraints Helps to identify information requirements Surfaces additional functional requirements
Guidance for Project (Static UML Model) Include all classes and their attributes for which the requirements suggest or imply the need to remember information (Hint: may include actors from use cases) Referred to as entity classes in project description During requirements analysis, classes are real world entities from the problem domain, not the solution domain Identify all associations between classes in the model Identify any association classes Identify cardinality of associations in model Identify relationships among classes in the model Generalization Aggregation Add applicable constraint rules No need to identify operations Create data dictionary to describe classes and attributes of static model
Subtopics Class diagram Object diagram Activity diagram Statechart diagram
Object Diagram Snapshot of objects and their relationships at a point in time Also referred to as an instance diagram Represents the state of the system at a point in time Can be used to show an example configuration of objects Contains object with values Class diagram contains classes and attributes Useful when the possible connections between objects are complicated Example
Links Connection between object instances UML Notation Connection between object instances Instance of an association between classes E.g, Frank works on Distance Learning Link exists between two objects if and only if there is an association between their corresponding classes Example
Subtopics Class diagram Object diagram Activity diagram Statechart diagram
Activity Diagram Activity diagram Activity start state activity Describes sequence of activities with support for both conditional and parallel behavior Variant of the state diagram in which most of the states are activity states Activity A state of doing something, such as typing activity transition end state
Conditional Behavior in Activity Diagrams Branch Delineates conditional behavior Single incoming transition Several guarded outgoing transitions Only one of the outgoing guarded transitions can be taken Merge Multiple incoming transitions Single output transition Marks end of conditional behavior started by a branch branch merge
Parallel Behavior in Activity Diagrams Fork Delineates parallel behavior Single incoming transition Several outgoing transitions When incoming transition is triggered, all outgoing transitions are taken in parallel Join Multiple incoming transitions Single output transition Marks end of parallel behavior started by a fork Outgoing transition is taken only when all activities with the incoming transitions have completed fork join
Example Activity Diagram
Other Concepts Supported by Activity Diagrams UML Notation for Decomposition Decomposition Activities can be broken down into subactivities Dynamic concurrency Used to show iterations Swimlanes Conveys the people or organization responsible for carrying out each activity Activities arranged in vertical zones separated by lines Each zone captures responsibilities of particular organization Denoted by multiplicity marker (*) UML Notation for Dynamic Concurrency
Example Activity Diagram with Swimlanes
Benefits of Activity Diagrams Useful for depicting workflow requirements Useful for capturing required sequencing of activities Useful for understanding business processes Useful for describing behavior with parallel processes Useful for analyzing a use case Can be used in lieu of or in combination with textual use case description
Subtopics Class diagram Object diagram Activity diagram Statechart diagram
Statechart Diagram Describes all possible states that a particular object can get into and how object’s state changes as a result of events that reach the object Relates events and states Represents lifetime behavior of a single object A particular statechart typically represents a single class
State Recognizable condition of an object between events Recognizable situation during the life of an object during which it satisfies some condition, performs some activity, or waits for some event Exists over a finite interval of time start state state end state
State Transition Relationship between two states that indicates when an event occurs that transitions the object from one state to another state Represented by the line between two states Syntax for state transition label consists of three optional parts Event [Condition]/Action state transition
Events Significant or noteworthy occurrence A discrete signal that happens at a point in time Has no duration May have associated arguments Example - telephone is taken off the hook event
Conditions Boolean function Optional on statecharts Condition is true for finite period of time When event occurs, condition must be true for state transition to occur If condition is false, state transition does not occur Condition may be used to indicate that event has occurred E.g., Closedown Requested Can be used on statechart without a corresponding explicit event Multiple conditions from a given state must be mutually exclusive condition
State Transition Actions Executed as a result of state transition Executes instantaneously at state transition Terminates itself Is optional action
Activities Activity or processing that executes for duration of state Activity begins on entry to state Activity ends on exit from state Examples of activities from Gomaa cruise control example Increase Speed Executes for duration of Accelerating state Maintain Speed Executes for duration of Cruising state Resume Cruising Executes for duration of Resuming state activity
Entry, Exit, and On Event Actions Entry action Action executed on entry into state Entry / action Exit action Action executed on exit from state Exit / action On event action Action executed while object is in a certain state and a certain event occurs that does not cause a state transition entry action exit action on event action
Transition to Self Transition in which the source and target states are the same Source state is exited and reentered so exit actions and entry actions are invoked Not equivalent to an internal transition, in which no state change occurs
Superstates Contains nested substates Substate inherits the transitions of its superstate Allows depiction of states at various levels of detail
Concurrent Statecharts At any point, the object is in two states, one from the top part of the state chart and one from the bottom part of the statechart Useful when an object has sets of independent behavior
When to Use Statecharts When an object exhibits state-dependent behavior State-independent with respect to an event Object always responds the same way to an event State-independent object For all events of interest, object always reacts the same way State-dependent object Reacts differently to events depending on the current state To model transactions To describe the behavior of an object across several use cases
Guidelines for Project Analyze classes from static UML model and identify those with state-dependent behavior Develop a statechart for each object with state-dependent behavior State names must be unique Must be able to exit from every state Flat statechart (no concurrency) Object is in one state at a time Concurrent statecharts Object is in one state from each sub-statechart at a time Events are considered instantaneous Happen at a moment in time Event name indicates something has just happened Show start states and end states on all statecharts Conditions must be Boolean
Backup Material
Scope Scope Lecture material on Use Case Modeling Context diagram Use case diagrams with accompanying textual description Lecture material on Static and Dynamic Modeling Using UML Class diagram Object diagram Activity diagram Statechart diagram
UML review All problems Given a textual description of several paragraphs, develop one or more of the artifacts on the previous slide Given one or more artifacts, develop one or more additional artifacts For example, given a use case with textual description, develop a statechart to depict the state-dependent behavior of a certain object Hints Follow UML notation very closely Follow guidance given in lecture notes very closely Rational Rose does not implement the full UML If you use Rose, you may need to augment once pasted in Word or Powerpoint Rose doesn’t do it is not a valid excuse on mid-term