Coding Katas for Software Testers
Tags: softwaretesting, testautomation, codingkatas, programming
Published: 2019-03-05 09:40:59

---
title: Coding Katas for Software Testers
published: true
description: I keep writing the same exercises to help me improve my programming that relate to testing e.g. CounterStrings, link checkers, etc. Can I consider these Katas?
tags: SoftwareTesting, TestAutomation, CodingKatas, Programming
canonical: https://www.eviltester.com/blog/eviltester/2019-02-27-programming-katas-for-testers/
---

What would be suitable Code Katas for people wanting to learn how to code to support their testing?

Code Katas are a pretty popular concept for programming:

- https://www.codewars.com/
- http://www.codingdojo.org/
- https://en.wikipedia.org/wiki/Kata_(programming)
- https://leanpub.com/codingdojohandbook


I don't do Code Katas. John Somnez writes about why he doesn't do [code katas here](https://simpleprogrammer.com/dont-code-katas/) and here is another take on [Code Katas from Micah Martin](https://8thlight.com/blog/micah-martin/2013/05/28/performing-code-katas.html)

## Why I don't do Code Katas

- Time
   - I don't really have time to dedicate to code Katas
- Usefulness
   - When I'm learning a language I really want the code to be useful, because that is what motivates me to learn more.
- I don't want to keep doing the same thing
   
But I realised recently that I might well do Code Katas, but I haven't called them that.

## My Code Katas

I have written CounterString implementations in:

- VBA (Excel) [code](https://github.com/eviltester/test-utils-written-in-excel)
- VB (code lost)
- Java [main code](https://github.com/eviltester/testtoolhub), [java](https://github.com/eviltester/testtoolhub/tree/master/src/main/java/uk/co/compendiumdev/javafortesters/domain/counterstrings)
- JavaScript [predictive](https://github.com/eviltester/TestingApp/tree/master/java/testingapps/compendiumdevapps/src/main/resources/web/apps/counterstrings), [reverse](https://github.com/eviltester/counterstringjs)

I have approached the writing of CounterString differently each time I created a new implementation.

And I have revisited my implementation as I learned more about the programming language.


## An Exercise

If you want to use CounterStrings as a way to practice your programming, and potentially consider it a Code Kata.

Here are my suggestions.


1. write code to generate a String starting with `*`, and then `3*`, etc. to the length of your CounterString, e.g this would create a ten character CounterString like `*3*5*7*9*1`. I describe this as [Forward CounterString Generation](https://www.eviltester.com/2018/05/counterstring-algorithms.html#forward-counterstrings)
2. write code to generate a CounterString that matches how [JamesBach describes it](http://www.satisfice.com/blog/archives/22) where the string ends with * and is of the required length and the number before each * is the position of the * in the string, so a 10 character CounterString would read `*3*5*7*10*`
3. instead of writing out your CounterString to the console, write it to a file
4. instead of writing out your CounterString to the console, write it to the clipboard
5. instead of writing out your CounterString to the clipboard, make it type it into a field
6. find a different implementation approach e.g. if you used recursion change it to do something else, if you didn't use recursion try that, if you were reversing strings try doing it without reversing strings
7. create automated scripts that execute your implementation and compare the output with a different implementation e.g. [James Bach's perl clip](http://www.satisfice.com/tools.shtml) this might initially be a pre-generated file or responses, but create one that calls PerlClip dynamically
7. for the 'ultimate' challenge, try writing an implementation that generates CounterStrings the way James Bach describes it, but does it dynamically so that you could stream the generation. I describe this as [Predictive Forward CounterString Generation](https://www.eviltester.com/2018/05/counterstring-algorithms.html#predictive-forward-counterstrings)

With each of these you will create something useful, that supports you in your work. And you'll learn something.

## Other Suggestions

Other code that I seem to keep writing:

- create a verb/noun text adventure game
- write a link checker
- write a calculator that takes a string e.g. "2+4+7" and returns the result
- write a test data generator using generative grammar

All of these can vary in complexity but provide useful learning tools. You'll find examples of all of the above in my [Github repos](https://github.com/eviltester) (but you might have to search a bit).

**How do you practice your programming and what exercises do you use to learn new languages?**

## Free Video Inside

{% youtube 3n1ENZ1KE60 %}


## Slides

{% slideshare GwLWV5jMZya5NG %}