I. Object-oriented design: a way to think about organizing programs what are the main tools we can use? A. main questions ------------------------------------------ QUESTIONS FOR OO DESIGN 1. What are appropriate objects? 2. What interfaces to specify? 3. a. When to use inheritance? b. When to use composition? 4. How can the design withstand change? ------------------------------------------ B. responsibility-driven design method 1. for each action, find an object to be responsible for it. 2. CRC cards a. on front (spec) ----------------------- CRC CARDS ClassName | Collaborators --- | Responsibilities | ... | ----------------------- b. MVC example -------------------------------------- CRC CARDS for Model, View, Controller View | Controller --- | Model Render the Model | Transform coordinates Controller | View --- | Model Interpret user input | | Distribute control | Model | --- | Maintain problem info| | Broadcast change | notification | ---------------------------------- c. Lottery example ---------------------------------- LottoCustomer | --- | remember how much | willing to lose | play lottery some # | Lottery of times | Lottery | --- | pick winning ticket | WinningTicket | UniformDiscrete tell how much ticket | has won | Ticket | --- | hold 7 distinct | integers | WinningTicket | --- | (as in Ticket) | tell number of matches| Ticket to a Ticket | UniformDiscrete | --- | remember how many to | pick from | give set of distinct | numbers of a size ---------------------------------- d. CRC cards on back (implementation design) C. exercises 1. ATM banking machine 2. A kitchen management system.