You are on page 1of 26

Software Engineering Principles

Behavioural Modelling

Syed Mohy U din


Roll no 21
Bscs 6 th
Domain Modelling
• Represents concepts or objects appearing in
the problem domain.
• Also captures relationships among objects.
• Three types of objects are identified
– Boundary objects
– Entity objects
– Controller objects
• Three different stereotypes on classes are used:
– <<boundary>> Cashier Interface
– <<entity>>
Account
– <<control>>
Withdrawal
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
Modelling Behaviours
• A behavioural model
shows the interactions
between objects to
produce some
particular system
behaviour that is
specified as a use-
case.
• Activity
Sequence diagrams,
diagrams, state • Where are people
diagrams, coming from?
collaboration diagrams
are used to model • Where are they going?
interaction between • How do they move
objects. from one space to the
other?
Modelling Behaviour
Phone SMS
Server
handleMessage(text, reciepient) sendMessage(sender, text,
reciepient):msgID getStatus(msgID): status
resend(msgID)
checkForMessages(receipient):msgID[]

• 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
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
Play
Move

Player Tic-tac-toe
• Initial and Refined Domain Model game

Board

Initial domain
model
PlayMoveBoundary PlayMoveController Board

Refined domain
model
Sequence Diagram

Boundary Controller
:board

move acceptMove checkMoveValidity


[invalidMove]
[invalidMove] announceInvalidMove
announceInvalidMove checkWinner
[game over]
[game over]
announceResult
announceResult
playMove
checkWinner
[game over] [game over]
announceResult announceResult
displayBoardPosi getBoardPositi
tions ons
[game not
over]
promptNextMove
Class Diagram

Board PlayMoveBoundary

int position[9]
announceInvalidMove
checkMove announceResult
Validity displayBoard
checkResult
playMove

Controller

announceInvalidMove
announceResult
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

register
customer
Customer Clerk
register
sales
Sales
Clerk
select
winners
Manager
Supermarket
Prize
scheme
Initial Domain Model

SalesHistory CustomerRegister
1 1*
*

SalesRecords CustomerRecord
Refined Domain Model
CustomerRegister
SalesHistory
1
* 1
*

SalesRecords CustomerRecord

RegisterCustomerBoundary RegisterCustomerController

RegisterSalesBoundary RegisterSalesController

SelectWinnersBoundary SelectWinnersControllers
Sequence Diagram:Select Winners
Use Case
:SelectWinner :SelectWinner :Sales :Sales :Customer :Customer

Boundary Controller History Record Register Record

Select SelectWinners
Winners SelectWinners
*computeSales

*browse

[for each winner]


find WinnerDetails [for each
announces winner]
browse
Sequence Diagram: Register Customer
Use Case
:RegisterCustomer :RegisterCustomer :Customer :Customer
Boundary Controller Register Record

register
register
checkDuplicate
*match

showError [duplicate]
showError
generateCIN
:Customer
create
register Record

displayCIN
Sequence Diagram: Register
Sales Use Case
:Register :Register
:Sales
Sales Sales
History
Boundary Controller

RegisterSales registerSales
registerSales
:Sales
create Record

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

confirm
Class Diagram

SalesHistory CustomerRegister

selectWinners findWinnerDetails
registerSales register

1
* 1
*

SalesRecords CustomerRecord
salesDetails name
address
computerSales
browse browse
create checkDuplicate
create
Thank
You

You might also like