Object-Oriented Design
Identifying Operations (or Responsibilities)
- Identify what can be done to objects. or
- Identify what objects can do for themselves. or
- Identify who is responsible for doing what.
- Terminology: operations, responsibilities, contracts, message passing,
encapsulation, data hiding
Example: BlackJack Program
- Card: display, report value (report suit? maybe internally) (modify value/suit? or set these in constructor only?)
- Deck: shuffle, deal next card, report how many cards left in deck
- Dealer: deal cards, add card to hand, show (sometimes partial) hand, calculate (partial) hand value, number of cards in hand, hit?, determine winner, reset hand
- Player: add card to hand, show hand, calculate hand value, number of cards in hand, hit?, reset hand