Code katas are small coding exercises to sharpen your programming skills. In this post, I’ll show you my favourite code kata. The core idea is to resolve a relatively simple programming problem, following an exaggerated version of coding best practices.

The rules

These rules have Java and Kotlin in mind; you may want to tweak them to suit your programming language.

The problem

Using your preferred programming language, design a loyalty program for a coffee shop. Customers collect one stamp per coffee; when they reach six stamps, they have one free coffee. The application exposes the following public operations:

If the customer reaches six stamps upon adding a new stamp, the application should create a free reward coffee.

Feel free to ask any clarification questions, give feedback or share solutions on Twitter @code_exercises. Have a look at my other code exercises.

The goals

Notes/assumptions