Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
1
Requirements
R i t 2
Modeling
Analysis
Modeling
4 3 5
Design
Modeling 6
Throwaway Incremental
Prototyping Software
Construction 7
Incremental
Software
Integration 8
Customer
10
11 System
12 Incremental 9 Testing
13 Prototyping 14
15
15
Copyright 2006 H. Gomaa
Copyright 2011 H. Gomaa 2
SWE 621:
Software Modeling and Architectural Design
Hassan Gomaa
5
Copyright 2011 H. Gomaa
MAX SIZE
Stack INDEX
X
Information
Hiding
Object
Stack Array
# Entries Top
Account
accountNumber : Integer
balance : Real
readBalance () : Real
credit (amount : Real)
debit (amount : Real)
open (accountNumber : Integer)
close ()
Withdraw,
Confirm,
Abort
Withdraw
Response
«business logic»
:Withdrawal
TransactionManager
«business logic»
WithdrawalTransactionManager
+ initialize ( )
+ withdraw (in accountNumber, in amount, out response)
+ confirm(accountNumber, amount)
+ abort (accountNumber, amount)
«database wrapper»
15.14a Analysis model DebitCard
«entity»
DebitCard + create
t (cardId)
( dId)
+ validate (in cardID, in PIN, out status)
cardId: String + updatePIN (cardId, PIN)
PIN: String + checkDailyLimit (cardId, amount)
startDate: Date + updateDailyTotal (cardId, amount)
expirationDate: Date + updateExpirationDate (cardId, expirationDate)
status:Integer + updateCardStatus (cardId, status)
limit: Real + updateDailyLimit (cardId, newLimit)
+ clearTotal (cardId)
total: Real
+ read (in cardId, out PIN, out expirationDate,
out status, out limit, out total)
+ delete (cardId)
Abstract Class
• Abstract Class
– Template for creating subclasses
– Has no instances
– Only used as superclass
– Defines common interface for subclasses
• Abstract operation
– Operation declared in abstract class but not
implemented
• Abstract Class defers implementation of some or all of its
operations to subclasses
• Different subclasses can define different implementations
of same abstract operation
Copyright 2011 H. Gomaa
Example of Inheritance
CheckingAccount SavingsAccount
- cumulativeInterest : Real = 0
- debitCount : Integer = 0
- lastDepositAmount : Real = 0
- maxFreeDebits : Integer = 3
- bankCharge : Real = 2.50
+ credit (amount : Real)
+ credit (amount : Real) + debit (amount : Real)
+ debit (amount : Real) + clearDebitCount ()
+ readLastDepositAmount () : Real + addInterest (interestRate : Real)
+ readCumulativeInterest () : Real
Copyright 2011 H. Gomaa
Example of Inheritance
Example of Inheritance
• Attributes of Savings Account Subclass
– Inherits accountNumber, balance
– Adds instance attributes cumulativeInterest, debitCount
– Adds static class attributes maxFreeDebits, bankCharge
• Operations
O i off Savings
S i Account
A S b l
Subclass
– Inherits specification & implementation of open, readBalance,
close
– Inherits specification of credit and debit but defines
implementation
– debit
• Debit balance
• Deduct bank Charge if debit Count > max Free Debits
– Adds Operations
• addInterest (interestRate) Add daily interest
• readCumulativeInterest () :Real
• clearDebitCount () Reinitialize debit Count to zero
Copyright 2011 H. Gomaa
Class Interface Specification
• Information hidden by class
• Class structuring criterion
• Assumptions made in specifying class
• A i i
Anticipatedd changes
h
• Superclass (if applicable)
• Inherited Operations (if applicable)
• Operations provided by class
• Function performed
• Precondition
• Postcondition
• Invariant
• Input parameters
• Output parameters
• Operations used by class (provided by other classes)
Copyright 2011 H. Gomaa
«data abstraction»
SensorActuatorRepository
+ initialize ( )
+ initialize ( )
+ withdraw (in accountNumber,
+ initializee ( ) + transfer
se ( + initializee ( )
i amount, outt w_response))
in
+ validatePIN (in cardId, in PIN, in fromAccountNumber, + query (in accountNumber,
+ confirm (accountNumber, amount)
out v_response) in toAccountNumber, out q_response)
+ abort (accountNumber, amount)
in amount, out t_response)
«database wrapper»
TransactionLog
«database wrapper»
DebitCard
«database wrapper»
CardAccount
+ create (cardId)
+ validate (in cardID, in PIN, out status)
+ updatePIN (cardId, PIN)
+ checkDailyLimit (cardId, amount) + read ( in cardId, out accountNumber)
+ updateDailyTotal (cardId, amount) + update (in cardId, in accountNumber)
+ updateExpirationDate (cardId, expirationDate)
+ updateCardStatus (cardId, status)
+ updateDailyLimit (cardId, newLimit)
+ clearTotal (cardId)
+ readd (in
(i cardId,
dId outt PIN,
PIN outt expirationDate,
i i D
out status, out limit, out total)
+ delete (cardId)
«database wrapper»
Account
«database
d t b wrapper» «database wrapper»
CheckingAccount SavingsAccount
1
Requirements
R i t 2
Modeling
Analysis
Modeling
4 3 5
Design
Modeling 6
Throwaway Incremental
Prototyping Software
Construction 7
Incremental
Software
Integration 8
Customer
10
11 System
12 Incremental 9 Testing
13 Prototyping 14
15
15
Copyright 2006 H. Gomaa
Copyright 2011 H. Gomaa 42