Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Vienna Development Method
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Bank system example=== As a very simple example of a VDM-SL model, consider a system for maintaining details of customer bank account. Customers are modelled by customer numbers (''CustNum''), accounts are modelled by account numbers (''AccNum''). The representations of customer numbers are held to be immaterial and so are modelled by a token type. Balances and overdrafts are modelled by numeric types. <syntaxhighlight lang="rsl"> AccNum = token; CustNum = token; Balance = int; Overdraft = nat; AccData :: owner : CustNum balance : Balance state Bank of accountMap : map AccNum to AccData overdraftMap : map CustNum to Overdraft inv mk_Bank(accountMap,overdraftMap) == for all a in set rng accountMap & a.owner in set dom overdraftMap and a.balance >= -overdraftMap(a.owner) </syntaxhighlight> With operations: ''NEWC'' allocates a new customer number: <syntaxhighlight lang="rsl"> operations NEWC(od : Overdraft)r : CustNum ext wr overdraftMap : map CustNum to Overdraft post r not in set dom ~overdraftMap and overdraftMap = ~overdraftMap ++ { r |-> od}; </syntaxhighlight> ''NEWAC'' allocates a new account number and sets the balance to zero: <syntaxhighlight lang="rsl"> NEWAC(cu : CustNum)r : AccNum ext wr accountMap : map AccNum to AccData rd overdraftMap map CustNum to Overdraft pre cu in set dom overdraftMap post r not in set dom accountMap~ and accountMap = accountMap~ ++ {r|-> mk_AccData(cu,0)} </syntaxhighlight> ''ACINF'' returns all the balances of all the accounts of a customer, as a map of account number to balance: <syntaxhighlight lang="rsl"> ACINF(cu : CustNum)r : map AccNum to Balance ext rd accountMap : map AccNum to AccData post r = {an |-> accountMap(an).balance | an in set dom accountMap & accountMap(an).owner = cu} </syntaxhighlight>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)