11.10.2013 Views

Slides Part 2 (OOA, pages 1-128, pdf, 4 slides per page)

Slides Part 2 (OOA, pages 1-128, pdf, 4 slides per page)

Slides Part 2 (OOA, pages 1-128, pdf, 4 slides per page)

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Sends = BankClerk: {give money(amount), no cover}<br />

Pre = accountnr is a valid account number, account.balance ≥ 0<br />

Post = If account.balance − amount ≥ 0:<br />

account.balance ′ = account.balance − amount<br />

is sent{give money(amount)}<br />

If account.balance − amount < 0:<br />

account.balance ′ = account.balance<br />

is sent{no cover}<br />

account.balance ′ ≥ 0<br />

=⇒ The class Account has the attribute balance.<br />

account.balance ≥ 0: Invariant. Contained in pre- and in postcondition.<br />

Note: the output event give money gets a parameter (These are not contained<br />

in the scenarios ).<br />

MORE EXAMPLES<br />

sd OpenAccountS1<br />

: Bank<br />

BankClerk Schufa<br />

open_new_customer_account<br />

alt<br />

[ClientKnown]<br />

customer_already_known<br />

[else]<br />

alt<br />

[queryOK]<br />

account_opened<br />

[else]<br />

account_not_opened<br />

ref<br />

85<br />

87<br />

SchufaQuery<br />

REMARK<br />

The precondition of the o<strong>per</strong>ation must be consistent with the scenarios.<br />

If it cannot be taken for granted that only valid account numbers can be given<br />

as a parameter of the o<strong>per</strong>ation withdraw money, then a scenario must be<br />

added that states how to treat the case of an invalid account number.<br />

Once such a scenario is added, the precondition “accountnr is a valid account<br />

number” may be dropped.<br />

Assumption: cd is sufficient to distinguish different customers<br />

86<br />

O<strong>per</strong>ation = open new customer account<br />

Description = A new customer wants to open an account. A query is sent to<br />

the Schufa before the account can be opened.<br />

Reads = supplied cd : Customer data<br />

Changes = —<br />

Sends = BankClerk: {customer already known},<br />

Schufa: {schufa query(cd))}<br />

Pre = —<br />

Post = If exists account : Account with account.customer data = cd:<br />

is sent{customer already known}<br />

Otherwise: is sent{schufa query(cd)}<br />

=⇒ The class Account has the attribute customer data.<br />

88

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!