02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister [email protected] DTU...
Transcript of 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister [email protected] DTU...
![Page 1: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/1.jpg)
02291: System IntegrationWeek 7
Hubert [email protected]
DTU ComputeTechnical University of Denmark
Spring 2018
![Page 2: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/2.jpg)
Recap
I Last WeekI Life cycle state machines (LSM’s): Describes the life cycle
of an objectI Protocol state machines (PSM’s): Describes the
communication protocol for provided/required interface of acomponent
I Today:I Sequence diagramsI Testing your model: Use case realizations
![Page 3: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/3.jpg)
Contents
Components and Synchronous Communication
Sequence Diagrams
Design Validation: Use Case Realization
![Page 4: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/4.jpg)
Synchronous– vs Asynchronous Calls:
Asynchronous Callpublic class Atm implements AtmToBank {
// From the user interface
public void enterPin(String pin) {
new Thread(() -> {bank.verifyPin(pin)}).start();
}
// From the bank
public void pinOk() { ... }
public void pinNotOk() { ... }
}
Synchronous Callpublic class Atm {
// From the user interface
public void enterPin(String pin) {
boolean pinOk = bank.verifyPin(pin);
}
}
![Page 5: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/5.jpg)
Synchronous– vs Asynchronous Calls:
Asynchronous Callpublic class Atm implements AtmToBank {
// From the user interface
public void enterPin(String pin) {
new Thread(() -> {bank.verifyPin(pin)}).start();
}
// From the bank
public void pinOk() { ... }
public void pinNotOk() { ... }
}
Synchronous Callpublic class Atm {
// From the user interface
public void enterPin(String pin) {
boolean pinOk = bank.verifyPin(pin);
}
}
![Page 6: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/6.jpg)
Synchronous version of the Bank
![Page 7: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/7.jpg)
Closer View
Port Bank to ATM (BA):Provided interface I Port ATM to Bank (AB):
Required interface
![Page 8: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/8.jpg)
Protocol for interfaces BankToAtm andBankToATMSync
I Asynchronous version ofthe protocol state machine
withdrawingwithdrawverifyingidle
sm: BankToAtm {protocol}
/ [^p inNotOk]
/ [^wi thdrawOk]/ [^withdrawNoOk]
withdraw(i,a)/ [ ^p inOk]verifyPin(p)
I Synchronous version ofthe protocol state machine
BankToATMSync. {protocol}
Idle Withdraw
withdraw(i,a)/[result = false]
withdraw(i,a)/[result = true]
verifyPin(p)/[result = true]
verifyPin(p)/[result = false]
![Page 9: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/9.jpg)
Bank component with Implementation
Bank
Bank
CustomerAccount
ClearingCompanyToBank BankToATM *
«delegate»«delegate»
BankToATMPort
*
![Page 10: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/10.jpg)
Detailed Class Diagram for the Bank Component
Bankname: String...accountFor(acct): AccountverifyPin(acct,pin)withdraw(acct,amount)
«interface»ClearingCompanyToBank
verifyPIN(acct,pin): bool
Customernameaddress...
Accountnumber : IBANbalance : intwithdraw(amount:int): bool...
BankToATMPortverifyPIN(acct,pin): boolwithdraw(acct,amt): bool
1 cc *
1..*
1..*
*c*
«interface»BankToATMSync
verifyPIN(acct,pin): boolwithdraw(acct,amt): bool *
1 b
![Page 11: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/11.jpg)
Behaviour Design BankToATMPort
I Behaviour of class BanktToATMPort
I Behaviour of class Bank
![Page 12: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/12.jpg)
Protocol conformance
Protocol for the interface BankToATMSyncBankToATMSync. {protocol}
Idle Withdraw
withdraw(i,a)/[result = false]
withdraw(i,a)/[result = true]
verifyPin(p)/[result = true]
verifyPin(p)/[result = false]
BankToATMPort lifecycle state machine
![Page 13: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/13.jpg)
Summary: Components
I Ports in components haveI provided and required interfacesI Each interface: Protocol state machine
I Implementing Components1) Subcomponents delegating ports2) Set of classes
I Classes implement provided interface of a portI Classes use the required interface of a portI Lifecycle state machine and protocol state machine have to
conform to each other
![Page 14: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/14.jpg)
Contents
Components and Synchronous Communication
Sequence Diagrams
Design Validation: Use Case Realization
![Page 15: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/15.jpg)
Example: Interaction Diagrams
Sequence DiagramCommunication Diagram
![Page 16: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/16.jpg)
Example Sequence Diagram
![Page 17: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/17.jpg)
Creation and deletion of participants
![Page 18: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/18.jpg)
Synchronous– vs Asynchronous Calls:Synchronous
b.m(4);
c.n(...) // Starts after m has returned
Synchronous calls
m(4)
n(...)
a:A b:B c:C
Asynchronous// (new Thread(){ public void run() {b.m(4);}}).start();
new Thread(() -> {b.m(4);}).start(); // Using Lambdas from Java 8
c.n(...) // Starts immediately after m has been called
![Page 19: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/19.jpg)
Synchronous– vs Asynchronous Calls:Synchronous
b.m(4);
c.n(...) // Starts after m has returned
Synchronous calls
m(4)
n(...)
a:A b:B c:C
Asynchronous// (new Thread(){ public void run() {b.m(4);}}).start();
new Thread(() -> {b.m(4);}).start(); // Using Lambdas from Java 8
c.n(...) // Starts immediately after m has been called
Asynchronous calls
m(4)
n(...)
a:A b:B c:C
![Page 20: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/20.jpg)
ATM to Bank: Asynchronous Version
![Page 21: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/21.jpg)
ATM to Bank: Synchronous Version
![Page 22: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/22.jpg)
Interaction Frames Example
Realising an algorithm using a sequence diagram
public void dispatch() {
for (LineItem lineItem : lineItems) {
if (lineItem.getValue() > 10000) {
careful.dispatch();
} else {
regular.dispatch();
}
}
if (needsConfirmation()) {
messenger.confirm();
}
}
![Page 23: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/23.jpg)
Realisation with Interaction Frames
![Page 24: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/24.jpg)
Interaction Frame Operators I
![Page 25: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/25.jpg)
Nested sequence diagrams
![Page 26: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/26.jpg)
Usages of sequence diagrams
I Abstract: show the execution (i.e. exchange of messages)of a system
I ConcreteI Design (c.f. CRC cards)I Visualize program behaviourI Visualize model execution ! use case realization
![Page 27: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/27.jpg)
System design: Detailed Use Case Check out
I Use Case Name: Check outI Summary: Checks out a book from the libraryI Actors: UserI Preconditions: trueI Basic course of events
I 1. User scans his library cardI 2. User repeats
I 2.1 select check outI 2.2 scan the bookI 2.3 System confirms loan
I Alternative paths. . .
I PostconditionsI Book is loaned by the user
![Page 28: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/28.jpg)
Use Case scenarios as Sequence Diagrams
Main scenariosd: borrow book success
scanLibraryCard(bor)
true
checkOut()
scanBook(b)
true
loop
UserLibrary
![Page 29: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/29.jpg)
System design for the main use case scenariosd: borrow book success
scan librarycard(bor)
true
checkOut()
scan book(b)
canBorrow()
isOverdue()
false
loop
true
checkout(bor)
true
true
loop
UserLibrary bor:Borrower
[b in bor.books]
b1:Book b2:Book
![Page 30: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/30.jpg)
Contents
Components and Synchronous Communication
Sequence Diagrams
Design Validation: Use Case Realization
![Page 31: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/31.jpg)
UML Models
I Many diagrams, but only one modelI Different Views on the system
I Functionality: Use Case diagram, state machines, activitydiagram, . . .
I Structure: Component diagram, Class diagramI Validation: Interaction diagram
![Page 32: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/32.jpg)
Dependence between models: Consistency conditions
1) Components are implemented by class diagramsI Provided interfaces in ports have to be implemented by
classesI Object life cycle behaviour conforms to the the protocol
statemachines2) Use case scenarios can be realized by the system
! use sequence diagrams to show this
![Page 33: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/33.jpg)
Use Case Diagram Library System
![Page 34: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/34.jpg)
Detail Use Case Check outI Use Case Name: Check outI Summary: Checks out a book from the libraryI Actors: UserI Preconditions: trueI Basic course of events
I 1. User scans his library cardI 2. User repeats
I 2.1 select check outI 2.2 scan the bookI 2.3 System confirms loan
I Alternative pathsI 3.a. User has overdue books
I System rejects loan with message ’overdue books’I 3.b User has more then 5 books on loan
I System rejects loan with message ’too many books’I 1.a User is not registered with the systemI . . .
I PostconditionsI Book is loaned by the user
![Page 35: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/35.jpg)
Implementation: Component Diagram (synchronousversion)
<<inter face>>LibraryInterface
scanLibraryCard()checkOutscanBook()checkIn...
LibraryInterface
LibrarySystem
![Page 36: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/36.jpg)
Implementation: Protocol State Machine (PSM):Library Interface (synchronous version)
More functionality
...
/[result = false]
/[result = true]
check in
scanBook/[result = (false,'too many books') or result = (false,'overdue books') or
result = true]
check outscanLibraryCard
![Page 37: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/37.jpg)
Implementation: Class Diagram
{pre: bor.canBorrow() post: dueDate = Date.today + 3 weeks and bor.books->containing(self) }
{body: books->size <= 5 and books->forAll(b | not(b.overdue))}
<<inter face>>LibraryInterface
scanLibraryCard()checkOutscanBook()checkIn...
{inv: overdue iff dueDate <> null and today > dueDate}
BookoverduedueDateregister()deregister()checkout()checkin()
BorrowercanBorrow()
Libraryscan library card()check outscan book()check in...
0..5*
user
*
![Page 38: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/38.jpg)
Implementation: Object Life Cycle State Machine(LSM): Class Library
user ok
can borrow?
...
...
book scannedUser scannedIdle
[not cb] / return "book can't be borrowed"
scanBook(l)
[cb] / b.checkOut(); return "ok"
/ cb := bor.canBorrow()
[users->contains(l)]
[not users->contains(l)] / return err-msg
scanLibraryCard (l)
![Page 39: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/39.jpg)
Implementation: LSM Class Book
registered
not registered
overdue
borrowedavailable
deregister
register
check in
check in
when Today > dueDate
checkOut(b) / dueDate := today + 3 weeks; b.books := b.books->containing(tself)
![Page 40: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/40.jpg)
Use Case success scenario realisationsd: borrow book success
scan librarycard(bor)
true
checkOut()
scan book(b)
canBorrow()
isOverdue()
false
loop
true
checkout(bor)
true
true
loop
UserLibrary bor:Borrower
[b in bor.books]
b1:Book b2:Book
![Page 41: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/41.jpg)
Use Case fail realisation
sd: borrow book failure: overdue books
scanLibraryCard(bor)
true
checkOut()
scanBook(b)
canBorrow()
isOverdue()
true
loop
false
false
loop
UserLibrary bor:Borrower
[b in bor.books]
b1:Book b2:Book
![Page 42: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/42.jpg)
Checking that a use case realization is correct
1 The sequence diagram shows correctly the user interactionof the use case scenario
2 All messages appear in the respective interfaces of theclass
3 All messages are admissiable according to the protocolstate machines (PSM)
4 All message sequences are admissible according to thebehaviour specification
![Page 43: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/43.jpg)
1) User interactions
I Basic course of eventsI 1. User scans his library cardI 2. User repeats
I 2.1 select check outI 2.2 scan the bookI 2.3 System confirms loan
sd: borrow book success
scan librarycard(bor)
true
checkOut()
scan book(b)
canBorrow()
isOverdue()
false
loop
true
checkout(bor)
true
true
loop
UserLibrary bor:Borrower
[b in bor.books]
b1:Book b2:Book
![Page 44: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/44.jpg)
2) Messages belong to interfaces
{pre: bor.canBorrow() post: dueDate = Date.today + 3 weeks and bor.books->containing(self) }
{body: books->size <= 5 and books->forAll(b | not(b.overdue))}
<<inter face>>LibraryInterface
scanLibraryCard()checkOutscanBook()checkIn...
{inv: overdue iff dueDate <> null and today > dueDate}
BookoverduedueDateregister()deregister()checkout()checkin()
BorrowercanBorrow()
Libraryscan library card()check outscan book()check in...
0..5*
user
*
sd: borrow book success
scan librarycard(bor)
true
checkOut()
scan book(b)
canBorrow()
isOverdue()
false
loop
true
checkout(bor)
true
true
loop
UserLibrary bor:Borrower
[b in bor.books]
b1:Book b2:Book
![Page 45: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/45.jpg)
3) Messages conform to the PSM (LibraryInterface)Class Library implements the LibraryInterface
More functionality
...
/[result = false]
/[result = true]
check in
scanBook/[result = (false,'too many books') or result = (false,'overdue books') or
result = true]
check outscanLibraryCard
sd: borrow book success
scan librarycard(bor)
true
checkOut()
scan book(b)
canBorrow()
isOverdue()
false
loop
true
checkout(bor)
true
true
loop
UserLibrary bor:Borrower
[b in bor.books]
b1:Book b2:Book
![Page 46: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/46.jpg)
4a) Messages follow the LSM for class Library
user ok
can borrow?
...
...
book scannedUser scannedIdle
[not cb] / return "book can't be borrowed"
scanBook(l)
[cb] / b.checkOut(); return "ok"
/ cb := bor.canBorrow()
[users->contains(l)]
[not users->contains(l)] / return err-msg
scanLibraryCard (l)
sd: borrow book success
scan librarycard(bor)
true
checkOut()
scan book(b)
canBorrow()
isOverdue()
false
loop
true
checkout(bor)
true
true
loop
UserLibrary bor:Borrower
[b in bor.books]
b1:Book b2:Book
![Page 47: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/47.jpg)
4b) Messages follow the LSM for class Book
registered
not registered
overdue
borrowedavailable
deregister
register
check in
check in
when Today > dueDate
checkOut(b) / dueDate := today + 3 weeks; b.books := b.books->containing(tself)
sd: borrow book success
scan librarycard(bor)
true
checkOut()
scan book(b)
canBorrow()
isOverdue()
false
loop
true
checkout(bor)
true
true
loop
UserLibrary bor:Borrower
[b in bor.books]
b1:Book b2:Book
![Page 48: 02291: System Integration · 02291: System Integration Week 7 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018](https://reader035.fdocuments.in/reader035/viewer/2022071500/611f1874d2bfca5166568a60/html5/thumbnails/48.jpg)
Alternative: Construct the sequence diagram from theLSM’s