Keywords: object-oriented, analysis, design, UML, java

## Detailed Design

A major task of detailed design is to spell out, in detail, the attributes and methods needed by each class (the second and third "compartments" of the representation for each class in a class diagram.)

The methods needed by each class are implicit in the responsibilities assigned to the class in the CRC cards, and become explicit in the Interaction Diagrams. A responsibility listed for a class on its CRC card generally maps into a method or methods in the detailed design. Likewise, any time an object belonging to a given class is shown as the recipient of a message in either a Sequence or Collaboration Diagram, the class needs a corresponding method. Many of the needed attributes are also either explicitly or implicitly present in the diagrams; the need for others becomes evident as the code for the class is being written. (Thus detailed design and coding are a "round trip" process - detailed design dictates coding, and coding leads to elaboration of the detailed design.)

In designing this system, a few key design decisions were made:

- The class ATM is made an active class - that is, the ATM object has its own thread. Using the Java thread facllity leads to defining a run() method in this class whose body is executed by the ATM's thread. The fact that class ATM is active is indicated in class diagrams by enclosing it in a heavier outline.
- Certain signals initiate computation - e.g. the signals from the operator console when the state of the switch is changed, or from the card reader when a card is inserted. In the GUI simulation of the ATM, these signals are sent by the "actionPerformed()" method of the appropriate GUI button; in a real ATM they would be sent by the physical components themselves, which might then also need to be active classes. (Note: this forms an exception to the rule that a responsibility on a CRC card translates into a method in the design - in this case the class sends a signal, rather than receiving it, so it does not need a method directly corresponding to the responsibility.)
- The Transaction hierarchy consists of the abstract class Transaction and four concrete subclasses (Withdrawal, Deposit, Transfer and Inquiry). The class Transaction has a "virtual constructor" called makeTransaction() which asks the customer to choose a transaction type and then constructs and returns an object of the appropriate subclass. The Transaction class is made responsible for carrying out the Transaction use case and the Invalid PIN extension; for the former, it makes use of abstract methods getSpecificsFromCustomer() and completeTransaction() which are implemented concretely by each subclass.
- The class Receipt is abstract. The completeTransaction() method of each kind of transaction creates a concrete instance that contains the information relevant to that kind of transaction.
- The class Status is abstract. The send() method of NetworkToBank constructs a concrete instance that contains the information appropriate to the response received from the bank to a particular message.

In the design below, each class is developed in isolation. No attempt is made to connect each class to related classes as in the class diagram, because the resulting picture would not fit on a displayable web page. Therefore, this detailed design should be viewed in conjunction with the Class Diagram developed earlier.

- Detailed design for class ATM
- Component parts of the ATM
  - Detailed design for class CardReader
  - Detailed design for class CashDispenser
  - Detailed design for class CustomerConsole
  - Detailed design for class EnvelopeAcceptor
  - Detailed design for class Log
  - Detailed design for class NetworkToBank
  - Detailed design for class OperatorPanel
  - Detailed design for class ReceiptPrinter
- Detailed design for class Session
- The Transaction class hierarchy
  - Detailed design for class Transaction
  - Detailed design for class Withdrawal
  - Detailed design for class Deposit
  - Detailed design for class Transfer
  - Detailed design for class Inquiry
- Classes representing banking concepts, used by the above
  - Detailed design for class AccountInformation
  - Detailed design for class Balances
  - Detailed design for class Card
  - Detailed design for class Message
  - Detailed design for class Money
  - Detailed design for class Receipt
  - Detailed design for class Status

ATM
- id: int
- place: String
- bankName: String
- bankAddress: InetAddress
- cardReader: CardReader
- cashDispenser: CashDispenser
- customerConsole: CustomerConsole
- envelopeAcceptor: EnvelopeAcceptor
- log: Log
- networkToBank: NetworkToBank
- operatorPanel: OperatorPanel
- receiptPrinter: ReceiptPrinter
- state: int
- switchOn: boolean
- cardInserted: boolean
- OFF_STATE: final int
- IDLE_STATE: final int
- SERVING_CUSTOMER_STATE: final int
+ ATM(id: int, place: String, bankName: String, bankAddress: InetAddress)
+ run()
+ switchOn()
+ switchOff
+ cardInserted()
+ getID(): int
+ getPlace(): String
+ getBankName(): String
+ getCardReader(): CardReader
+ getCashDispenser(): CashDispenser
+ getCustomerConsole(): CustomerConsole
+ getEnvelopeAcceptor(): EnvelopeAcceptor
+ getLog(): Log
+ getNetworkToBank(): NetworkToBank
+ getOperatorPanel(): OperatorPanel
+ getReceiptPrinter(): ReceiptPrinter
- performStartup()
- performShutdown()

[ Links for this class ]

CardReader
- atm: ATM
+ CardReader(atm: ATM)
+ readCard(): Card
+ ejectCard()
+ retainCard()

[ Links for this class ]

CashDispenser
- log: Log
- cashOnHand: Money
+ CashDispenser(log: Log)
+ setInitialCash(initialCash: Money)
+ checkCashOnHand(amount: Money): boolean
+ dispenseCash(amount: Money)

[ Links for this class ]

CustomerConsole
+ CustomerConsole()
+ display(message: String)
+ readPIN(prompt: String): int throws Cancelled
+ readMenuChoice(prompt: String, menu: String []): int throws Cancelled
+ readAmount(prompt: String): Money throws Cancelled

[ Links for this class ]

EnvelopeAcceptor
- log: Log
+ EnvelopeAcceptor(log: Log)
+ acceptEnvelope() throws Cancelled

[ Links for this class ]

Log
+ Log()
+ logSend(message: Message)
+ logResponse(status: Status)
+ logCashDispensed(amount: Money)
+ logEnvelopeAccepted()

[ Links for this class ]

NetworkToBank
- log: Log
- bankAddress: InetAddress
+ NetworkToBank(log: Log, bankAddress: InetAddress)
+ openConnection()
+ closeConnection()
+ sendMessage(message: Message, out balances: Balances): Status

[ Links for this class ]

OperatorPanel
- atm: ATM
+ OperatorPanel(atm: ATM)
+ getInitialCash(): Money

[ Links for this class ]

ReceiptPrinter
+ ReceiptPrinter()
+ printReceipt(receipt: Receipt)

[ Links for this class ]

Session
- atm: ATM
- pin: int
- state: int
- READING_CARD_STATE: final int
- READING_PIN_STATE: final int
- CHOOSING_TRANSACTION_STATE: final int
- PERFORMING_TRANSACTION_STATE: final int
- EJECTING_CARD_STATE: final int
- FINAL_STATE: final int
+ Session(atm: ATM)>
+ performSession()
+ setPIN(int pin)

[ Links for this class ]

Transaction
# atm: ATM
# session: Session
# card: Card
# pin: int
# serialNumber: int
# message: Message
# balances: Balances
- TRANSACTION_TYPES_MENU: final String []
- nextSerialNumber: int
- state: int
- GETTING_SPECIFICS_STATE: final int
- SENDING_TO_BANK_STATE: final int
- INVALID_PIN_STATE: final int
- COMPLETING_TRANSACTION_STATE: final int
- PRINTING_RECEIPT_STATE: final int
- ASKING_DO_ANOTHER_STATE: final int
# Transaction(atm: ATM, session: Session, card: Card, pin: int)
+ makeTransaction(atm: ATM, session: Session, card: Card, pin: int): Transaction throws Cancelled
+ performTransaction(): boolean throws CardRetained
+ performInvalidPinExtension(): Status throws Cancelled, CardRetained
+ getSerialNumber(): int
# getSpecificsFromCustomer(): Message throws Cancelled
# completeTransaction(): Receipt throws Cancelled

[ Links for this class ]

Withdrawal
- from: int
- amount: Money
+ Withdrawal(atm: ATM, session: Session, card: Card, pin: int)
# getSpecificsFromCustomer(): Message throws Cancelled
# completeTransaction(): Receipt

[ Links for this class ]

Deposit
- to: int
- amount: Money
+ Deposit(atm: ATM, session: Session, card: Card, pin: int)
# getSpecificsFromCustomer(): Message throws Cancelled
# completeTransaction(): Receipt throws Cancelled

[ Links for this class ]

Transfer
- from: int
- to: int
- amount: Money
+ Transfer(atm: ATM, session: Session, card: Card, pin: int)
# getSpecificsFromCustomer(): Message throws Cancelled
# completeTransaction(): Receipt

[ Links for this class ]

Inquiry
- from: int
+ Inquiry(atm: ATM, session: Session, card: Card, pin: int)
# getSpecificsFromCustomer(): Message throws Cancelled
# completeTransaction(): Receipt

[ Links for this class ]

AccountInformation
+ ACCOUNT_NAMES: final String[]
+ ACCOUNT_ABBREVIATIONS: final String []

[ Links for this class ]

Balances
- total: Money
- available: Money
+ Balances()
+ setBalances(total: Money, available: Money)
+ getTotal(): Money
+ getAvailable(): Money

[ Links for this class ]

Card
- number: int
+ Card(number: int)
+ getNumber(): int

[ Links for this class ]

Message
+ WITHDRAWAL: final int
+ INITIATE_DEPOSIT: final int
+ COMPLETE_DEPOSIT: final int
+ TRANSFER: final int
+ INQUIRY: final int
- messageCode: int
- card: Card
- pin: int
- serialNumber: int
- fromAccount: int
- toAccount: int
- amount: int
+ Message(messageCode: int, cardNumber: Card, pin: int, serialNumber: int, fromAccount: int, toAccount: int, amount: Money)
+ toString(): String
+ setPIN(pin: int)
+ getMessageCode(): int
+ getCard(): Card
+ getPIN(): int
+ getSerialNumber(): int
+ getFromAccount(): int
+ getToAccount(): int
+ getAmount(): Money

[ Links for this class ]

Money
- cents: long
+ Money(dollars: int)
+ Money(dollars: int, cents: int)
+ Money(toCopy: Money)
+ toString(): String
+ add(amountToAdd: Money)
+ subtract(amountToSubtract: Money)
+ lessEqual(compareTo: Money): boolean

[ Links for this class ]

Receipt
- headingPortion: String []
# detailsPortion(): String []
- balancesPortion: String []
# Receipt(atm: ATM, card: Card, transaction: Transaction, balances: Balances)
+ getLines(): Enumeration

[ Links for this class ]

Status
+ toString(): String
+ isSuccess(): boolean
+ isInvalidPIN(): boolean
+ getMessage(): String

[ Links for this class ]

Page of links for non frames-enabled browsers.

###### Copyright © 2000, 2001, 2002 - Russell C. Bjork. Permission for non-commercial reproduction for educational use is hereby granted; all other rights are reserved.