On this episode of the Evil Geniuses Podcast, we continue our series on a first example of the video checkout system. To start off we recap some of the points from the first two parts and then move into the final stretch! We talk about the two main patterns that are present in this code, namely base charge for rental and extra charge for rental before getting into renaming decoupling and calculating a final cost. We add in some reminders about primitive obsession and take some handy lessons from the idea of a library and borrowing books, so stay tuned for that! For all this, and much more be sure to listen in as we go deep!
Key Points From This Episode:
- Recapping the patterns from the first two parts of this series.
- Base charge for rental and extra charge for rental as the two patterns.
- Renaming a commit and why it is more accurate now.
- The meaning of the number two in this context.
- Making it obvious that new movies have a base rental period.
- Looking to the library for an analogy on extra charges and new movies.
- Finally calculating the whole charge for the rental.
- Figuring out the title of the movie by removing a coupling.
- Writing exemplary code for others to follow.
- An HTML challenge to the listeners!
- And much more!
Commits
- rename element to rental
-
- Make the code tell a story
- rename base_cost_of_rental to base_charge_for_rental
-
- Making the code tell a consistent story
- extract #points_for_rental. remove comments, no longer necessary
-
- Repeat the pattern of the previous extractions
- extract base_rental_period from extra_charge_for_rental
-
- A new pattern spotted
- new releases do not have the concept of base rental period
-
- Trying to figure out what base_rental_period for new release movies is
- or maybe new releases have infinty base_rental_period
-
- I think we’ve got it!
- base_charge_for_rental can include extra_charge_for_rental
-
- Consolidating ideas
- rename base_charge_for_rental to chare_for_rental
-
- Consolidated idea
- extract base_charge_for_rental. It's also become obviou
-
- Doing the obvious move
- move base_charge to rental
-
- More obvious
- move extra_charge to Rental
-
- More obvious moves
- add Rental#charge method. Only public met
Information
- Show
- FrequencyUpdated Semimonthly
- PublishedOctober 31, 2018 at 7:00 AM UTC
- Length29 min
- Episode13
- RatingClean