40 likes | 161 Views
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 .
E N D
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
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)
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.