Announcing a new Kata – Leaderboard

by | Jun 2, 2015 | Code Kata | 2 comments

I’ve been interested for a while in the relationship between TDD and good design for a while, and theย  SOLID principles of Object Oriented Design in particular. I’ve got this set of 4 “Racing Car” exercises that I originally got from Luca Minudel, that I’ve done in coding dojos with lots of different groups. If you’ve never done them, I do recommend getting your editor out and having a go, at least at the first one. I think you get a much better understanding of the SOLID principles when you both know the theory, and have experienced them in actual code.

I find it interesting that in the starting code for each of the four Katas there are design flaws that make it awkward to write unit tests for the code. You can directly point to violations of one or more of the SOLID principles. In particular for the Dependency Inversion Principle, it seems to me there is a very direct link with testability. If you have a fixed dependency to a concrete class, that is always going to be harder to isolate for a unit test, and the Tyre Pressure exercise shows this quite clearly.

What bothers me about the 4 original exercises is that there are actually 5 SOLID principles, and none of them really has a problem with the Liskov Substitution Principle. So I have designed a new exercise! It’s called “Leaderboard” and I’ve put it in the same git repository as the other four.

I tried it out last week in a coding dojo with my colleagues at Pagero, and it seemed to work pretty well. The idea is that the Liskov principle violation means you can’t propely test the Leaderboard class with test data that only uses the base class “Driver”, you have to add tests using a “SelfDrivingCar”. (Ok, I confess, I’ve taken some liberties with what’s likely in formula 1 racing!) Liskov says that your client code (ie Leaderboard) shouldn’t need to know if it has been given a base class or a subclass, they should be totally substitutable. So again, I’m finding a link between testability and good design.

Currently the exercise is only available in Scala, Python and Java, so I’m very open to pull requests for translations into other programming languages. Do add a comment here or on github if you try my new Kata.

Hi โ€“ Iยดm Emily!

I am an independent consultant withย Bache Consultingย and chair of theย Samman Technical Coaching Society.ย  As a technical coach I work with software development organizations who want to get better at the technical practices needed to be agile, including Test-Driven Development, Refactoring and Incremental Design.ย I live in Gothenburg, Sweden, although I am originally from the UK. Iโ€™ve written two books: โ€œTechnical Agile Coaching with the Samman methodโ€ andย ย โ€œThe Coding Dojo Handbookโ€. I teach for bothย Oโ€™Reillyย andย ย Pluralsight. Iโ€™m married to Geoff Bache, creator ofย TextTest. I am also on Mastodon asย emilybache@sw-development-is.social.

Sociala ikoner med hovringseffekt

If youโ€™d like to know a bit more about me, my work, and the talks and workshops I offer, please visit my main website: EmilyBache.com. There, youโ€™ll find information about my background, upcoming events, and the services I provide as a technical coach and consultant. Itโ€™s a good place to start if you’re curious about how I can support your team in improving coding skills and agile practices.

Practical Coaching โ€“
Beyond the Blog

If youโ€™re enjoying the insights shared here on the blog, you might enjoy my training too.

โ€œTechnical Agile Coaching with the Samman Methodโ€ย offers a practical guide to improving how developers collaborate and write code. Youโ€™ll learn hands-on techniques for Test-Driven Development, Refactoring, and effective team coaching.

To learn more about the book, just click the link below.

Blog categories