Software Engineering :Behavioral Modelling - I Sequence diagram

AjitNayak20 24,054 views 27 slides Nov 12, 2017
Slide 1
Slide 1 of 27
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27

About This Presentation

Software Engineering :Behavioral Modelling - I Sequence diagram


Slide Content

Software Engineering Principles
AjitK Nayak, Ph.D.
[email protected]
Domain & BehaviouralModelling

Acknowledgements
•Slides of Prof. RajibMall, IIT, KGP

Domain Modelling
•Represents concepts or objects appearing in the
problem domain.
•Also captures relationships among objects.
•Threetypes of objectsare identified
–Boundary objects
–Entity objects
–Controller objects
•Three different stereotypes on classes are used:
–<<boundary>>
–<<entity>>
–<<control>>
Cashier Interface
Withdrawal
Account

Object Types
•Boundary Objects are objects that Interact with actors:
–User interface objects like screens, menus, forms, dialogs etc.
–Do not perform processing but validates, formats etc.
•Entity Objects are objects that Hold information:
–Such as data tables & files, e.g. Book, BookRegister
–Normally are dumb servers responsible for storing data,
fetching data etc.
–Elementary operations on data such as searching, sorting, etc.
–Entity Objects are identified by examining nouns in problem
description
•Controller Objects Coordinate the activities of a set of entity
objects
–Interface with the boundary objects
–Realizes use case behaviour
–Embody most of the logic involved with the use case
realization
–There can be more than one controller to realize a single use
case

ModellingBehaviours
•A behavioural model
shows the interactions
between objects to
produce some
particular system
behaviour that is
specified as a use-case.
•Sequence diagrams,
Activity diagrams, state
diagrams,
collaboration diagrams
are used to model
interaction between
objects.
•Where are people coming
from?
•Where are they going?
•How do they move from
one space to the other?

ModellingBehaviour
•How do we use the SMS Server interface?
•What is the order of executing the operations?
–sendMessage, getStatus, Resend?
–getStatus, sendMessage, checkForMessages?
•When do we use resend?
•We use Interaction diagrams to model this
Phone
handleMessage(text, reciepient)
SMS Server
sendMessage(sender, text, reciepient):msgID
getStatus(msgID): status
resend(msgID)
checkForMessages(receipient):msgID[]

Sequence Diagrams
•A sequence diagram is an interaction diagram that
shows how objects send messages with one another
and in what order?

Object Control

Corresponding Class Diagram

Message types
•Synchronous message
–Used when the sender waits until
the receiver has finished
processing the message, only
then does the caller continue (i.e.
a blocking call).
•Asynchronous message
–the sender does not wait for the
receiver to finish processing the
message.
–An open arrowhead is used to
indicate that a message is sent
asynchronously.
•Return message

If-Else (Alternatives)

Loops -Iteration

Example 1: Tic-Tac-Toe Computer Game
•A human player and the computer make alternate moves on a
33 square.
•A move consists of marking a previously unmarked square.
•The user inputs a number between 1 and 9 to mark a square
•Whoever is first to place three consecutive marks along a
straight line (i.e., along a row, column, or diagonal) on the
square wins.
•As soon as either of the human player or the computer wins,
–A message announcing the winner should be displayed.
•If neither player manages to get three consecutive marks along
a straight line,
–All the squares on the board are filled up,
–Then the game is drawn.
•The computer always tries to win a game.

Domain Modelling
•Use Case Model
Tic-tac-toe game
Play Move
Player
•Initial and Refined Domain Model
Board
Initial domain model
PlayMoveBoundary PlayMoveController Board
Refined domain model

Sequence Diagram
:playMove
Boundary
:playMove
Controller
:board
move
acceptMove
checkMoveValidity
[invalidMove]
announceInvalidMove
[invalidMove]
announceInvalidMove
[game over]
announceResult
announceResult
[game over]
checkWinner
playMove
checkWinner
[game over]
announceResult
[game over]
announceResult
getBoardPositionsdisplayBoardPositions
[game not over]
promptNextMove

Class Diagram
Board
intposition[9]
checkMoveValidity
checkResult
playMove
Controller
announceInvalidMove
announceResult
PlayMoveBoundary
announceInvalidMove
announceResult
displayBoard

Supermarket Prize Scheme -I
•Supermarket needs to develop software to encourage
regular customers.
•Customer needs to supply his:
–Residence address, telephone number, and the
driving licence number.
•Each customer who registers is:
–Assigned a unique customer number (CN) by the
computer.
•A customer can present his CN to the staff when he
makes any purchase.
–The value of his purchase is credited against his CN.

Supermarket Prize Scheme -II
•At the end of each year:
–The supermarket awards surprise gifts to ten
customers who make highest purchase.
•Also, it awards a 22 carat gold coin to every customer:
–Whose purchases exceed Rs. 10,000.
•The entries against the CN are reset:
–On the last day of every year after the prize winner’s
lists are generated.

Use Case Model
Supermarket
Prize scheme
register
customer
register
sales
select
winners
Customer
Sales Clerk
Manager
Clerk

Initial Domain Model
SalesHistory
SalesRecords
1
*
CustomerRecord
CustomerRegister
1
*

Refined Domain Model
SalesHistory
SalesRecords
1
*
CustomerRecord
CustomerRegister
1
*
RegisterCustomerBoundary
RegisterSalesBoundary
SelectWinnersBoundary
RegisterCustomerController
RegisterSalesController
SelectWinnersControllers

Sequence Diagram:SelectWinners
Use Case
:SelectWinner
Boundary
:SelectWinner
Controller
:Sales
History
:Sales
Record
:Customer
Register
:Customer
Record
Select
Winners
SelectWinners
announces
SelectWinners
*computeSales
*browse
[for each winner]
find WinnerDetails [for each winner]
browse

Sequence Diagram: Register Customer
Use Case
:RegisterCustomer
Boundary
:RegisterCustomer
Controller
:Customer
Register
:Customer
Record
register
register
*match
displayCIN
create
:Customer
Record
checkDuplicate
[duplicate]
showError
generateCIN
register
showError

Sequence Diagram: Register Sales
Use Case
:Sales
Record
create
RegisterSales
:Register
Sales
Boundary
:Sales
History
:Register
Sales
Controller
registerSales
confirm
registerSales
confirm

Sequence Diagram: Refined Register
Sales Use Case
:Register
Sales
Boundary
:Sales
History
registerSales
confirm
:Sales
Record
create
RegisterSales

Class Diagram
SalesHistory
selectWinners
registerSales
CustomerRegister
findWinnerDetails
register
SalesRecords
computerSales
browse
create
salesDetails
CustomerRecord
browse
checkDuplicate
create
name
address
1
*
1
*

Thank You