Friday, November 25, 2016

Gilded Rose Kata

I am writing TDD in Ruby book that has a chapter on Gilded Rose Kata. I have watched the presentations by Sandi Metz and Paul on this kata. They take different approaches to solve the problem. Sandi Metz's presentation was more engaging. I thought it was a great idea when she gradually refactored by trapping one type of cheese at a time by short-circuiting the code path for a certain cheese and make those tests fail and gradually making them pass one at a time. I don't think inheritance is the right choice in the final design. The problem is we are not inheriting any behavior from the superclass. Only the state is shared between the superclass and the subclasses so composition would have been the right choice.

I liked Paul's design of wrapping the item class and not using any dynamic class creation like Sandi Metz. Paul had a great examples of making the code express the domain concepts. But fell short in the end because he failed to recognize the data duplication and perhaps missed an opportunity to make it more expressive. Sandi Metz failed to raise the level of abstraction in the unit tests. Surprising thing is when she is describing what the test does, it could have easily been made a domain specific assertion like assert_quality_decrease etc. Hopefully, my book will address these shortcomings and perhaps I will push myself to produce something that I use in a conference talk.

Paul's presentation was a bit dry but he still had some good refactoring patterns and discussion about De Morgan's Law. I never thought what I had learned in high school would be relevant to coding today.

Emily Bache Presentation
Ruby Code to Use as a Starting Point
If you would like to download the vimeo video, follow this link:

No comments:

Post a Comment