Lecture 21 (Detailed Design Dynamic 2008)
Transcript of Lecture 21 (Detailed Design Dynamic 2008)
Software EngineeringITCS 3155Fall 2008
Dr. Jamie PaytonDepartment of Computer ScienceUniversity of North Carolina at Charlotte
November 18, 2008
Lecture 21Detailed Design
Dynamic Modeling with UML
22
Announcements
Deliverable 3 due dateNovember 25 at 11:59 pm
Deliverable 4 due dateDecember 1611:59 pm
Final examDecember 1611:30 am – 2:30 pmWoodward 130
READ: Transforming conceptual models, Ch. 11.3
44
Detailed Design Stages
Mid-level designSpecifying software at level of medium-size components• Compilation units or class
Their propertiesTheir relationshipsTheir interactions Essentially:• DESCRIPTR• Design patterns (later)
Low-level designActivity of filling in small details at lowest level of abstractionPAID
5
Mid-level Design and Modeling
Static modelingCaptures structure of parts of software system• UML Class Diagrams
Dynamic modelingCaptures behavior (interactions) of parts of software system• UML Sequence Diagrams
Static and dynamic models are complementaryNeed both to capture design of software system
6
Mid-level Design and Dynamic Modeling
Goal is to express the behavior of the system as it executes over time
Capture the interactions between individuals• Communication between individuals that exchange information to
accomplish a task
Individuals involved may be users, actors, objects (instances of classes)
7
UML Interaction Diagrams
Notations for dynamic modeling of collaborations among individualsUML interaction diagrams
Sequence diagram• Shows sequence of messages passed among communicating individuals• Highlight temporal nature of communication
Communication diagram• Shows messages passed among communicating individuals• Highlights collaborations
Interaction overview diagram• Activity diagram + Sequence diagrams
Timing diagram• Shows change in state of individual over time
12
UML Sequence Diagrams
Most widely used notation for describing interactionsClearly expresses message flow between individualsHighlights time ordering of interactions
13
UML Sequence Diagram Notation:Frame
Rectangle that encloses the diagram with pentagon-shaped name compartment
Name can be simple name or operation name (with params)
:User :Button
press
actionPerformed(event)toggle
:ButtonListener :Light
getState()
sd ButtonPress name compartment
14
UML Sequence Diagram Notation:Lifeline
Represents a participating individual Usually an object (instance of class)
Modeled as rectangle with dashed line extending downTime is represented vertically in diagramDashed line represents individual’s existenceRectangle is labeled with lifeline identifier
Lifelineclient
:Component
supplier
create
Xdestroy
sd UseComponent
15
Lifeline Creation and DestructionNew object appears at the point it is createdDestroyed object has a truncated lifeline
marked with an XPersistent objects have lifelines that run the length of the diagram
client
:Component
supplier
create
Xdestroy
sd UseComponent
16
Lifeline Identifier Format
Namesimple name, or “self”• Used when interaction depicted is “owned” by the individual
SelectorExpression to select an individual from a collection• Format not specified in UML
typeNameType of the individual• Format not specified in UML
Can omit name or :typeNameBut not both!
name[selector] : typeName
17
UML Sequence Diagram Notation:Message Arrows
Three typesSynchronous messagesAsynchronous messagesSynchronous message return or instance creation
:User :Button
press
actionPerformed(event)toggle
:ButtonListener :Light
getState()
sd ButtonPress
18
Message Specification Format
VariableSimple name of a variable assigned a resultOptional; if omitted, so is the equals sign
nameSimple name of the message
argumentListComma-separated list of arguments in parenthesesPossible formats:• varName = paramName• paramName = argumentValue• —Optional; parentheses may appear even if omitted
Message specification may be * (any message)
variable = name argumentList
19
Message Specification Examples
hellohello()msg = getMessage( helloMessage )x = sin( a/2 )x = sin( angle = a/2 )trim( result = aString )Warning
Assigning a value to a parameter and assigning a returned “out” parameter to a variable cannot be distinguishedUse variable/parameter assignments in correct order of parameters• Don’t define assignment based on names of parameters
20
UML Sequence Diagram Notation:Execution Occurrence
Indicates an object is activeObject is active if one or more operations is active• Operation is executing
Process is running code• Operation is suspended
Waiting on return of control from synchronous message
:User :Button
press
actionPerformed(event)toggle
:ButtonListener :Light
getState()
sd ButtonPress
executionoccurrence
21
Combined Fragments
A combined fragment is a marked part of an interaction diagram that shows
BranchingLoopsConcurrent executionOther properties
22
Optional Fragment
A portion of an interaction that may be doneEquivalent to a conditional (guarded) statement• Conditional based on satisfaction of guard
A guard is a Boolean expression Placed in square brackets in UMLExamples• [isEnrolled]• [isAuthorized]• [else] is a special guard
true if every other guard is false
23
Optional Fragment Example
self:PrintServer
[isCmprsd]
sd print( f : File )
f:File
opt
isCmprsd=isCompressed()
decompress()
:Printer
print(f)
Denoted by “opt” fragment operatorSingle “opt” operand is enclosed by rectangle
24
Alternative Fragment
A combined fragment with mutually exclusive conditional statements
Equivalent to a case or switch statementOperator is the keyword “alt”“alt” can be applied to one or more operands
self:Light
turnOff()
:Bulb
sd toggle()
[state==on]alt
turnOn()[state==off]
25
Break Fragment
A combined fragment that uses a guarded statement to determine to discontinue “typical” execution
Similar to a break statementOperator is the keyword breakOperates only on one operand
26
Break Fragment Example
self:PrintServer
[isCmprsd]
sd print( f : File )
f:File
opt
isCmprsd=isCompressed()
decompress()
:Printer
print(f)
[!readable]break
print(errMsg)
readable=canRead()
stderr
27
Loop Fragment
Single loop body operand that may have a guardOperator has the form loop( min, max ) [guard]
Parameters are optional• if omitted, so are the parentheses
min is a non-negative integermax is a non-negative integer • min <= max <= *• max is optional; if omitted, so is the comma
In this case, max = min
Default guard is true