ch5: software specification. 1 dynamic modeling using uml static models: dynamic models:

27
Ch5: Software Specification

Post on 21-Dec-2015

224 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Ch5: Software Specification. 1 Dynamic modeling using UML  Static models:  Dynamic models:

Ch5: Software Specification

Page 2: Ch5: Software Specification. 1 Dynamic modeling using UML  Static models:  Dynamic models:

2

Dynamic modeling using UML

Static models:

Dynamic models:

Page 3: Ch5: Software Specification. 1 Dynamic modeling using UML  Static models:  Dynamic models:

3

Interaction diagrams

Purpose of an interaction diagram:

Sequence diagrams

Collaboration diagrams:

Page 4: Ch5: Software Specification. 1 Dynamic modeling using UML  Static models:  Dynamic models:

4

Uses of interaction diagrams

Refinement of use cases

Understand system dynamics

Page 5: Ch5: Software Specification. 1 Dynamic modeling using UML  Static models:  Dynamic models:

5

Notation for sequence diagrams

Classifiers Objects (instances of classes) and classes.Arranged horizontally.Objects respond to messages by invocation of methods, while Classes respond to messages by invocation of static methods. Represented by a rectangleObjects have labels name: ClassName, where name is optionalObjects with no name are called anonymous objectsClasses have labels in the form ClassName

aStudent:Student :Seminar

Page 6: Ch5: Software Specification. 1 Dynamic modeling using UML  Static models:  Dynamic models:

6

Notation for sequence diagrams (contd..)

Actors:Communicate with objectsModeled using the stick figureActors initiate, take active part in usage scenariosLabeled by ActorName

Page 7: Ch5: Software Specification. 1 Dynamic modeling using UML  Static models:  Dynamic models:

7

Notation for sequence diagrams

LifelineDenotes the life of an object during a sequence.Contains an X at the point at which the object is removed from the memory.In languages such as C++, where memory needs to be managed by the programmer a destroy method needs to be calledDotted vertical line below the class/object.

Page 8: Ch5: Software Specification. 1 Dynamic modeling using UML  Static models:  Dynamic models:

8

Notation for sequence diagrams

Focus of control: Long narrow rectangle placed on top of a lifelineDenotes an object performing an action to fulfill a message

Page 9: Ch5: Software Specification. 1 Dynamic modeling using UML  Static models:  Dynamic models:

9

Notation for sequence diagrams

Message:Conveys information from one object to another, or from an actor toan object, or from object to an actor.Represented by a horizontal arrow.Source and the target of the method are objects, message label is the signature of the method invoked in response to the message.If either the source or target is human actor, then the message is labeled with a brief text describing the information being communicated.

Wish to enroll isEligible(aStudent)

Page 10: Ch5: Software Specification. 1 Dynamic modeling using UML  Static models:  Dynamic models:

10

Drawing sequence diagrams

Place actors, objects, and classes that participate in the interaction at the top of the diagram, across the X-axis.

Place messages the objects send and receive along the Y-axis, in order of increasing time from top to bottom.

Page 11: Ch5: Software Specification. 1 Dynamic modeling using UML  Static models:  Dynamic models:

11

Sequence diagrams (contd..)

Object lifeline:

Focus of control:

Page 12: Ch5: Software Specification. 1 Dynamic modeling using UML  Static models:  Dynamic models:

12

Basic sequence diagrams

Object1:Class1 Object2:Class2

Activations

Messages

Lifelines

Page 13: Ch5: Software Specification. 1 Dynamic modeling using UML  Static models:  Dynamic models:

13

Basic sequence diagrams (contd..)

Object1:Class1 Object2:Class2

Destroy

Page 14: Ch5: Software Specification. 1 Dynamic modeling using UML  Static models:  Dynamic models:

14

Basic sequence diagrams

Object1:Class1 Object2:Class2

Return values (optional)

Page 15: Ch5: Software Specification. 1 Dynamic modeling using UML  Static models:  Dynamic models:

15

Basic sequence diagrams

Object1:Class1 Object2:Class2

[Condition to exit]

Repetition or a loop is depicted as a rectangle.Condition to exit is placed at the bottom of the rectangle.

Page 16: Ch5: Software Specification. 1 Dynamic modeling using UML  Static models:  Dynamic models:

16

Basic sequence diagrams

Object1:Class1 Object2:Class2

Self Call

Page 17: Ch5: Software Specification. 1 Dynamic modeling using UML  Static models:  Dynamic models:

17

Basic sequence diagrams

Object1:Class1 Object2:Class2

Messages can be sent conditionallyConditions can also be depicted on the sequence diagrams

[Condition true]

[Condition false]

Page 18: Ch5: Software Specification. 1 Dynamic modeling using UML  Static models:  Dynamic models:

18

Sequence diagram: Example

:Computer :PrinterServer :Printer

Print(File)Print(file)

Page 19: Ch5: Software Specification. 1 Dynamic modeling using UML  Static models:  Dynamic models:

19

Sequence diagram: Example

:Computer :PrinterServer :Printer :Queue

Print(File)Print(file)

Store(File)

[Printer free]

[Printer busy]

Page 20: Ch5: Software Specification. 1 Dynamic modeling using UML  Static models:  Dynamic models:

20

Collaboration diagrams

Displays object interactions organized around objects and their links to one another.

Do not explicitly show the lifeline of an object

Can show both create and destroy message Do not show the focus of control explicitly

Each message’s sequence number can be an indicator Show how one object is linked to another

Page 21: Ch5: Software Specification. 1 Dynamic modeling using UML  Static models:  Dynamic models:

21

Collaboration Diagrams (contd..)

Objects: Rectangles containing object signature Object signature consists of object name: object class

•Object name optional, starts with a lower case letter

•Class name (mandatory), starts with an upper case letter

•Objects connected by lines

•Actor symbol may appear Messages:

Labeled like C and Java function calls

• Followed by round brackets, and can have parameters and return values

Are followed by an arrow to show direction Messages may be numbered, starting from 1

Page 22: Ch5: Software Specification. 1 Dynamic modeling using UML  Static models:  Dynamic models:

22

Collaboration diagrams

How to draw collaboration diagrams:

Page 23: Ch5: Software Specification. 1 Dynamic modeling using UML  Static models:  Dynamic models:

23

Collaboration diagrams: Example

:Computer

:PrinterServer

:Queue

:Printer

1: Print(file)

[Printer free]2. Print(file)

[Printer busy]3. Store(file)

Page 24: Ch5: Software Specification. 1 Dynamic modeling using UML  Static models:  Dynamic models:

24

Common uses

Use sequence diagrams to model flows of control by time ordering

Use collaboration diagrams to model flows of control by organization

Page 25: Ch5: Software Specification. 1 Dynamic modeling using UML  Static models:  Dynamic models:

25

Sequence & Collaboration Diagrams: Example

For an item to be purchased, the Sales Assistant enters the name of the item on the screen. The system finds the item, and then determinesthe total stock available. The system then displays the item. Draw anUML Sequence and Collaboration diagram for the above usage scenario.

Page 26: Ch5: Software Specification. 1 Dynamic modeling using UML  Static models:  Dynamic models:

26

Sequence Diagram

:ProcessOrderScreen :Item :StockItem

Name of ItemfindItem(ItemName)

getQuantity(itemNum)

Display Results

:SalesAssitant

Page 27: Ch5: Software Specification. 1 Dynamic modeling using UML  Static models:  Dynamic models:

27

Collaboration Diagram

:ProcessOrderScreen

:Item

:StockItem

1. Enter item name

2.findItem(itemName)

3.getQuantity(itemNum)