1 / 4

Exploring Object Construction in Revised Roulette Code: Cheat, Refactor, and Design Solutions

Dive into the modified Roulette code that highlights object construction problems akin to the Picassa Expression Hierarchy. Experience the new betting mechanism that interprets inputs like "even" and automatically determines the suitable Bet subclass. Uncover the new cheating feature and understand its mechanics. Identify the code responsible for calculating payouts for specific bets and participate in refactoring a particularly flawed function. We will explore four distinct design solutions, emphasizing that the best design often depends on the trade-offs you are willing to accept.

trixie
Download Presentation

Exploring Object Construction in Revised Roulette Code: Cheat, Refactor, and Design Solutions

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