html5-img
1 / 4

Construction Problems

As you Arrive… Snarf the RouletteRevised code. This is a new version of Roulette that I’ve modified exemplify problems with object construction similar to the Expression Hierarchy of Picassa .

trixie
Télécharger la présentation

Construction Problems

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. As you Arrive… Snarf the RouletteRevised code. This is a new version of Roulette that I’ve modified exemplify problems with object construction similar to the Expression Hierarchy of Picassa. Run and explore the code. Note that I’ve changed the way you pick a bet – now it just parses a bet like “even” and figures out the appropriate Bet subclass to use. As you look, answer to questions: I’ve added a new feature – it’s now possible to cheat. Figure out how to cheat and how cheating works. Where is the code that knows how much money a particular bet should pay out? Once you’ve finished that poke around and find a very ugly function in the code. That’s what we’ll be refactoring today. Construction Problems

  2. Key Points to Keep in Mind • Today we will explore 4 different solutions to the same design problem. All of them, I think, could be considered reasonable. • Not all designs are equally good. But sometimes the answer to what is the best design is “it depends”. It depends on the tradeoffs you’re willing to make. • In particular, you always pay for complexity (but very often that it worth it)

  3. Key Points to Keep in Mind 2. Design ideas come from the process of refactoring the code. When you simplify ugly code, new approaches often suggest themselves.

  4. 4 Designs

More Related