Professional Documents
Culture Documents
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 8
Case Study 1 – Bank example
Requirements
Open an account for a customer (savings or chequing)
Deposit
Withdraw
Display details of an account
Change LOC
Produce monthly statements
Print a list of customers
…
Ambiguities
What is the difference between savings and chequing?
Many others …
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 9
Case Study 1 – Bank example
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 10
Requirements to Code?
How to bridge
the gap between
??? requirements
and code?
Code
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 11
The waterfall model of the lifecycle
FEASIBILITY STUDY
REQUIREMENTS
ANALYSIS
SPECIFICATION
GLOBAL DESIGN
DETAILED DESIGN
IMPLEMENTATION
VALIDATION &
VERIFICATION
DISTRIBUTION
PROJECT PROGRESS
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 12
Arguments for the waterfall
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 13
The waterfall model of the lifecycle
FEASIBILITY STUDY
REQUIREMENTS
ANALYSIS
DESIGN AND
SPECIFICATION
IMPLEMENTATION
GLOBAL DESIGN
DETAILED DESIGN
IMPLEMENTATION
VALIDATION &
VERIFICATION
DISTRIBUTION
PROJECT TIME
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 14
Problems with the waterfall
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 15
Quality control?
Analysts
Designers
Implementers
Testers
Customers
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 16
Impedance mismatches
As Management requested it. As the Project Leader defined it. As Systems designed it.
As Programming developed it. As Operations installed it. What the user wanted.
(Pre-1970 cartoon; origin unknown)
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 17
How to think about requirements?
Use Cases
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 18
Bank Requirements – Use Cases
Banking system
Open
System Account
boundary
Deposit
Actors
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 19
Bank Use Cases
Challenge question:
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 20
Use Case – Open Account
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 21
Design of Bank – Identify Classes
TELLER
CUSTOMER
SAVINGS_ACCOUNT
CHEQUING_ACCOUNT
MAIN_MENU
BALANCE_INQUIRY
INTEREST_RATE ………
Where do we start?
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 22
Test Driven Development
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 23
TDD
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 24
EiffelStudio – create a new project
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 25
Call the new project bank
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 26
Compile and Run
print(“hello world!”)
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 27
Compile often!
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 28
ETester – Create a tests cluster
www.cs.yorku.ca/eiffel/etester
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 29
Create class account_test
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 30
Clusters and Classes
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 31
Ace file – Directory Structure
d0
d1 d2 d3
d4
root
root_class: make
default
precompiled ("C:\Eiffel54\precomp\spec\windows\base-time-etester")
assertion (check)
assertion (require) …
cluster
root_cluster: "C:\eiffel54_projects\bank2"
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 33
Project Configuration (Ace file)
Root Class
ACCOUNT_TEST
All contracts
turned on
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 34
Write Test
test_create_account: BOOLEAN is
local
c: CUSTOMER
do
comment("test_create_account")
create c.make("Archie Fox")
Result := equal(c.name, "Archie Fox")
end
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 35
The Test specifies a Design
ANY
CUSTOMER
name: STRING
invariant
name /= Void
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 36
EiffelStudio – create feature tool
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 37
customer.e
indexing
description: "A bank customer“
feature -- Access
name: STRING
-- of customer
invariant
name_not_void: name /= Void
end
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 38
ETester GUI – Green bar
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 39
Test: A customer with a savings account
test_create_customer_with_account: BOOLEAN is
local
a1,a2: SAVINGS_ACCOUNT
c: CUSTOMER
initial_deposit: REAL
do
initial_deposit := 500
create a1.make(initial_deposit)
check a1.balance = initial_deposit end
create c.make(a1, "Archie Fox")
a2 := c.account
Result := equal(c.name, "Archie Fox") and
a2 = a1 and a2.balance = initial_deposit
end
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 40
Red bar
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 41
Use debugger to find problem
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 42
EiffelStudio – BON tool
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 43
Client-Supplier relationship
CUSTOMER
SAVINGS_ACCOUNT
name: STRING
balance: REAL
account: ACCOUNT account
invariant
invariant
name /= Void balance >= 0
account /= Void
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 44
Open Account Use case (revisited)
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 46
test_withdraw
test_withdraw: BOOLEAN is
local
sa1, sa2: SAVINGS_ACCOUNT
initial_deposit: REAL
do
comment("test_withdraw")
initial_deposit := 500
create sa1.make(initial_deposit)
create sa2.make(200)
sa1.withdraw(300)
Result := equal(sa1, sa2)
end
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 47
Bank design (BON static diagram)
ANY
SAVINGS_ACCOUNT
balance: REAL
CUSTOMER withdraw (amount: REAL)
require
name: STRING
account amount > 0
account: ACCOUNT
amount <= balance
invariant ensure
name /= Void balance = old balance - amount
account /= Void
invariant
balance >= 0
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 48
EiffelStudio feature tool – withdraw
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 49
Run tests
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 50
Object equality
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 51
is_equal
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 52
equal
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 53
withdraw_negative
test_withdraw_negative_amount: BOOLEAN is
local
a1, a2: SAVINGS_ACCOUNT
initial_deposit: REAL
do
comment("test_withdraw_negative_amount")
initial_deposit := 500
create a1.make(initial_deposit)
create a2.make(200)
a1.withdraw(-100) – what happens here?
Result := equal(a1, a2)
end
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 54
Contract Violation
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 55
Violation Test Case
In make:
add_violation_case (agent test_withdraw_negative_amount)
test_withdraw_negative_amount is
local
a: SAVINGS_ACCOUNT
initial_deposit: REAL
do
comment("test_withdraw_negative_amount")
initial_deposit := 500
create a.make(initial_deposit)
a.withdraw(-100) –- a violation here is expected
end
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 56
(expected) Violation case
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 57
BON static diagram
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 58
Bank Challenge question
Department of Computer Science, York University Slides based on Object Oriented Software Construction 29/12/2003 3:22 PM 59