Monday Februaryjackie/teaching/lectures/2019... · 2019. 8. 30. · tests TEST_ACCOUNT feature Test...
Transcript of Monday Februaryjackie/teaching/lectures/2019... · 2019. 8. 30. · tests TEST_ACCOUNT feature Test...
![Page 1: Monday Februaryjackie/teaching/lectures/2019... · 2019. 8. 30. · tests TEST_ACCOUNT feature Test Commands for Contract Violations test_withdraw_postcondition_violation local acc:](https://reader034.fdocuments.us/reader034/viewer/2022051916/600843341e987d14a7417499/html5/thumbnails/1.jpg)
Monday February 4
Lecture 9
![Page 2: Monday Februaryjackie/teaching/lectures/2019... · 2019. 8. 30. · tests TEST_ACCOUNT feature Test Commands for Contract Violations test_withdraw_postcondition_violation local acc:](https://reader034.fdocuments.us/reader034/viewer/2022051916/600843341e987d14a7417499/html5/thumbnails/2.jpg)
releasedETFD
![Page 3: Monday Februaryjackie/teaching/lectures/2019... · 2019. 8. 30. · tests TEST_ACCOUNT feature Test Commands for Contract Violations test_withdraw_postcondition_violation local acc:](https://reader034.fdocuments.us/reader034/viewer/2022051916/600843341e987d14a7417499/html5/thumbnails/3.jpg)
Once Routine EDfresh
awl - M¥7-
T →
*⇐--
←1st time
⇒ - - -
→ ①
Yetignored .
![Page 4: Monday Februaryjackie/teaching/lectures/2019... · 2019. 8. 30. · tests TEST_ACCOUNT feature Test Commands for Contract Violations test_withdraw_postcondition_violation local acc:](https://reader034.fdocuments.us/reader034/viewer/2022051916/600843341e987d14a7417499/html5/thumbnails/4.jpg)
Approximating Once Routines a Javad ) breaking singleton .
to n
-
-
→ ¥44" di →
If- data
7¥.EE#::q:i:h*.sdda?¥÷•*÷:÷÷:÷÷g:÷÷÷dl.seeIRCI.es ) ;
![Page 5: Monday Februaryjackie/teaching/lectures/2019... · 2019. 8. 30. · tests TEST_ACCOUNT feature Test Commands for Contract Violations test_withdraw_postcondition_violation local acc:](https://reader034.fdocuments.us/reader034/viewer/2022051916/600843341e987d14a7417499/html5/thumbnails/5.jpg)
Approximating Once Routines a Java G) Separation ofConcerns .
. Data(Data Aces
€p
data
Static- I
-
BankData dl = neeI I
f
ra¥a¥¥÷private .data
access
-
![Page 6: Monday Februaryjackie/teaching/lectures/2019... · 2019. 8. 30. · tests TEST_ACCOUNT feature Test Commands for Contract Violations test_withdraw_postcondition_violation local acc:](https://reader034.fdocuments.us/reader034/viewer/2022051916/600843341e987d14a7417499/html5/thumbnails/6.jpg)
Singleton Pattern : Coded )
does←d§#④D's
-0¥O
⑦D=aeate-aess.ua/cexYTe's expanded
D-, ) →¥77'Estoyto
→
-
z- -
= -
![Page 7: Monday Februaryjackie/teaching/lectures/2019... · 2019. 8. 30. · tests TEST_ACCOUNT feature Test Commands for Contract Violations test_withdraw_postcondition_violation local acc:](https://reader034.fdocuments.us/reader034/viewer/2022051916/600843341e987d14a7417499/html5/thumbnails/7.jpg)
class BANK-
D- A -2Singleton Pattern : Gdek
. "
aIdataon.IE?aaaeeResukmake.#-⇒→
EOE→d⇐¥##⇒¥001€-
![Page 8: Monday Februaryjackie/teaching/lectures/2019... · 2019. 8. 30. · tests TEST_ACCOUNT feature Test Commands for Contract Violations test_withdraw_postcondition_violation local acc:](https://reader034.fdocuments.us/reader034/viewer/2022051916/600843341e987d14a7417499/html5/thumbnails/8.jpg)
dtaeaee"
- -.±
.
others.de?Yeanxseane
ofRANK
-
DATAusing
constructor
this
class
ACGNQdajia-A-f.cat?..da.daeaV
"
Ei÷:IEIa⑧end
![Page 9: Monday Februaryjackie/teaching/lectures/2019... · 2019. 8. 30. · tests TEST_ACCOUNT feature Test Commands for Contract Violations test_withdraw_postcondition_violation local acc:](https://reader034.fdocuments.us/reader034/viewer/2022051916/600843341e987d14a7417499/html5/thumbnails/9.jpg)
Banian\
aeaee4B#m€BANkDATAo_A
IR→create data
.make ? X
![Page 10: Monday Februaryjackie/teaching/lectures/2019... · 2019. 8. 30. · tests TEST_ACCOUNT feature Test Commands for Contract Violations test_withdraw_postcondition_violation local acc:](https://reader034.fdocuments.us/reader034/viewer/2022051916/600843341e987d14a7417499/html5/thumbnails/10.jpg)
class
Account
make
↳¥dd④:LBEATd
deEtat,
data2 : B
-
D deft→ data isIida.datadata:
-HII. dataad end f
2nd timedata I = data ?
that { B- RAJ.
data
once routine To called
![Page 11: Monday Februaryjackie/teaching/lectures/2019... · 2019. 8. 30. · tests TEST_ACCOUNT feature Test Commands for Contract Violations test_withdraw_postcondition_violation local acc:](https://reader034.fdocuments.us/reader034/viewer/2022051916/600843341e987d14a7417499/html5/thumbnails/11.jpg)
Singleton Pattern : Adem
⇒ttime,
calling 1B- RAS .
data
→- O
→- - O
![Page 12: Monday Februaryjackie/teaching/lectures/2019... · 2019. 8. 30. · tests TEST_ACCOUNT feature Test Commands for Contract Violations test_withdraw_postcondition_violation local acc:](https://reader034.fdocuments.us/reader034/viewer/2022051916/600843341e987d14a7417499/html5/thumbnails/12.jpg)
DATA_ACCESS +
data: DATA -- A shared data object. once create Result.make end
Invariantshared_instance: data = data
DATA +
data +
DATA_ACCESS
v: VALUE -- An example query.c -- An example command.
make -- Initialize a data object.
CLIENT_1
APPLICATION_2 +
CLIENT_2
APPLICATION_3 +
CLIENT_3
SUPPLIER_OF_SHARED_DATAAPPLICATION_1 +
Singleton Design Patternclient supplier
C) =-D ADACGONT reference type expanded type
@ Too A-D€
-
-
I
data routine
![Page 13: Monday Februaryjackie/teaching/lectures/2019... · 2019. 8. 30. · tests TEST_ACCOUNT feature Test Commands for Contract Violations test_withdraw_postcondition_violation local acc:](https://reader034.fdocuments.us/reader034/viewer/2022051916/600843341e987d14a7417499/html5/thumbnails/13.jpg)
⇐
of : = 02
⇐ O . f Co2 )=ol := f CoD
![Page 14: Monday Februaryjackie/teaching/lectures/2019... · 2019. 8. 30. · tests TEST_ACCOUNT feature Test Commands for Contract Violations test_withdraw_postcondition_violation local acc:](https://reader034.fdocuments.us/reader034/viewer/2022051916/600843341e987d14a7417499/html5/thumbnails/14.jpg)
.:¥:D: teams
.
not bl a nbz a b3 → I kind-
Tbl n bz a 763 → another
kind.
![Page 15: Monday Februaryjackie/teaching/lectures/2019... · 2019. 8. 30. · tests TEST_ACCOUNT feature Test Commands for Contract Violations test_withdraw_postcondition_violation local acc:](https://reader034.fdocuments.us/reader034/viewer/2022051916/600843341e987d14a7417499/html5/thumbnails/15.jpg)
Violation of -
fmgkchoxeprino.pl#--II
(- - tartrate
I
[-
* Tnf- rate
![Page 16: Monday Februaryjackie/teaching/lectures/2019... · 2019. 8. 30. · tests TEST_ACCOUNT feature Test Commands for Contract Violations test_withdraw_postcondition_violation local acc:](https://reader034.fdocuments.us/reader034/viewer/2022051916/600843341e987d14a7417499/html5/thumbnails/16.jpg)
Without Inheritance : Collection of Students
JAnders : a
-aj%%"
I-# I
E- = I I
↳y,morph eaton
![Page 17: Monday Februaryjackie/teaching/lectures/2019... · 2019. 8. 30. · tests TEST_ACCOUNT feature Test Commands for Contract Violations test_withdraw_postcondition_violation local acc:](https://reader034.fdocuments.us/reader034/viewer/2022051916/600843341e987d14a7417499/html5/thumbnails/17.jpg)
Inheritance :
Code Reuse
TO*
Bug poor
-\
Precursor ( →→
M pretenses!E"defined adass I --
M€-01200117020
![Page 18: Monday Februaryjackie/teaching/lectures/2019... · 2019. 8. 30. · tests TEST_ACCOUNT feature Test Commands for Contract Violations test_withdraw_postcondition_violation local acc:](https://reader034.fdocuments.us/reader034/viewer/2022051916/600843341e987d14a7417499/html5/thumbnails/18.jpg)
tests
TEST_ACCOUNTfeature Test Commands for Contract Violations test_withdraw_postcondition_violation local acc: BAD_ACCOUNT_WITHDRAW do create acc.make ("Alan", 100) Violation of Postcondition with tag "balance_deduced" expected acc.withdraw (50) end
acc
BAD_ACCOUNT_WITHDRAWfeature Redefined Commands withdraw (amount: INTEGER) ++ do Precursor (amount) Wrong Implementation balance := balance + 2 * amount end
ACCOUNTfeature Commands withdraw (amount: INTEGER) require non_negative_amount: amount > 0 affordable_amount: amount ≤ balance do balance := balance amount ensure balance_deduced: balance = old balance amount end
model
€00
&I
* e
a o→ ⇒ "
" "
→ -00