Showing posts with label Mentoring. Show all posts
Showing posts with label Mentoring. Show all posts

Sunday, April 7, 2019

The Beverages Prices Refactoring kata: a kata to practice refactoring away from an awful application of inheritance.

I created the Beverages Prices Refactoring kata for the Deliberate Practice Program I’m running at Lifull Connect offices in Barcelona (previously Trovit). Its goal is to practice refactoring away from a bad usage of inheritance.

The code computes the price of the different beverages that are sold in a coffe house. There are some supplements that can be added to those beverages. Each supplement increases the price a bit. Not all combinations of drinks and supplements are possible.

Just having a quick look at the tests of the initial code would give you an idea of the kind of problems it might have:

If that’s not enough have a look at its inheritance hierarchy:

To make things worse, we are asked to add an optional cinnamon supplement that costs 0.05€ to all our existing catalog of beverages. We think we should refactor this code a bit before introducing the new feature.

We hope you have fun practicing refactoring with this kata.

Sunday, June 5, 2016

Kata: Revisiting Tire Pressure Monitoring System in Java

Some weeks ago we did Luca Minudel's Tire Pressure Monitoring System refactoring kata as part of a mentoring program that Álvaro García and I were doing at Magento Barcelona.

We had done this kata several times before in Java and in Ruby, presented it at some events (Refactoring legacy code driven by tests (Java version) at SCBCN, Refactoring legacy code driven by tests (Java version) at Gran Canaria Ágil, Refactoring legacy code driven by tests (Ruby version) at SCBCN, Refactoring legacy code driven by tests (Ruby version) at Perl 2015 workshop, Refactoring legacy code driven by tests (Ruby version) at Socrates Canarias 2016), and also commented it in a series of blog posts.

In each iteration, we've added things we have learned from the feedback we've received. Thanks to all the people who gave us feedback, (specially to Johan S. Cortes for remembering us to protect the original pressure alarm knowledge).

This is the code of the rehearsal and this is the code of the live coding session at Magento.

We'd like to thank Luca Minudel, once more, for this great exercise. It's small and very focused so it's great for reflecting on concepts such as DIP, testability, seams, and context independence, and also showing some dependency-breaking and refactoring techniques in a short session.

Wednesday, May 18, 2016

The Ohce kata, a short and simple exercise to practice outside-in TDD using test doubles

I created this short and simple kata to practice outside-in TDD using test doubles for the mentoring Álvaro and I are doing in Magento Barcelona:

I hope you enjoy doing it.