A Katalogue of Code Katas recorded in a Code Kata
What is a Code Kata?
A hands-on programming exercise which helps hone your skills through practice.
Many of us learn best by doing. We build confidence and expertise through continual practice. We also learn by teaching. A Code Kata may help you build proficiency by implementing algorithms in various languages to solve specific problems. A Code Kata may also help you practice leveraging the APIs provided in a library, like Eclipse Collections or Java Streams. Sharing code katas you develop with a community of developers will help you learn even more.
The first set of Code Katas I ever encountered were written and shared by Pragmatic Programmer, Dave Thomas. The following is a link to his site with 21 Code Katas. These code katas are an amazing resource for developers looking to practice solving different programming problems.
The Eclipse Collections Java library also has a set of code katas which are intended to teach developers about the library. I am one of the project leads for Eclipse Collections, and I continue to look for opportunities to create new katas or enhance the existing ones to make the library more convenient to learn.
In addition to the Eclipse Collections Katas, there are other open source Code Katas that I have written to help developers learn various JVM languages and libraries. I have also demonstrated via blogs and tweets how the same code katas can be implemented in non-JVM programming languages. I have recently implemented the Deck of Cards Kata in Smalltalk and the Pet Kata in Python.
Nikhil Nanivadekar, Leo Lima and myself also implemented the Deck of Cards Kata in four JVM Languages (Java, Kotlin, Groovy, Scala) for a talk we gave at Oracle CodeOne 2018 and Devnexus 2019 called JVM.Languages.Compare.
Learn to Kata and Kata to Learn
In 2020, an article I contributed was published in the book “97 Things Every Java Programmer Should Know”.
The article I contributed is available at the link below on Medium.
Learn to Kata and Kata to Learn
Every Java developer needs to continuously learn new skills as the Java ecosystem constantly evolves. The Java…
I continue to use the approach described in this article to create new code katas. Any developer can use this approach to develop and share their own code katas. I followed this approach in creating the Kata of Katas I will describe in the rest of this blog.
Kata of Katas
The “Kata of Katas” is a code kata I wrote to record the Code Katas that I have implemented in various languages and libraries over the years. The kata is basically a Java code implementation of the README in this repo which I describe as a “Katalogue” of code katas.
I first came up with the domain model I wanted to implement to represent the code katas. I created classes for
Library. I implemented the classes as Java Enums and made
Library implement an interface named
Technology. I associated
Kata with an
Kata is constructed in the Java Enum with a var arg array of
Technology. This creates the first challenge for a developer to solve in the kata — How to get an
Library for a
Kata from an
Start with the tests
I wrote some tests to answer some questions given the domain model above. I wanted to be able to answer:
- Which technologies have been used in which katas?
- What katas are common between certain languages and libraries?
- What is the top language and top library used in the katas
There are three methods (
countByEach) I will use from the Eclipse Collections API to answer the above problems and another method (
selectInstancesOf) to determine the languages and libraries for a kata.
Here are the tests with solutions.
Delete the solutions & share the code
I deleted my solutions and created a module for the Kata of Katas in the Code Katas Repo, along with a separate module for the solutions so developers can compare their solutions to mine. Like the other katas in the repo, the Kata of Katas is open sourced under the Apache 2.0 License. Now the Kata of Katas can be completed by any developer using Java and Eclipse Collections, or any other programming language or library a developer is interested in learning and practicing with.
Social Code Katas
Sharing code katas I build in open source has become a regular practice in my professional life. There is another optional step I did not write about in the article in 97 Things.
- Socialize your kata with the community via social media channels
It might seem obvious to those who regularly participate in open source communities that a key to increasing awareness and impact is socializing the work that you do. Even before I committed the code for my kata to a Git repo, I started socializing the kata I was developing with my followers on Twitter as I was writing and refactoring the solutions.
As a result of this tweet, José Paumard shared his solutions to the kata using Java Streams on the thread.
It’s possible that other developers might find the challenge interesting enough to share their solutions in various languages or using other libraries.
Now that the Kata of Katas is committed to a repo in GitHub, I decided to write this blog to share it with my followers on Medium. After this blog is published, I will share the link to the blog on Twitter and LinkedIn. Then more developers can learn about the existence of the kata.
Thank you for taking the time to read this blog. I hope you enjoyed reading about the Kata of Katas and can find the time to try the kata out on your own in your favorite Java IDE.
I am a Project Lead and Committer for the Eclipse Collections OSS project at the Eclipse Foundation. Eclipse Collections is open for contributions. If you like the library, you can let us know by starring it on GitHub.
Other Java Articles You May like
20+ Essential Java Libraries and APIs Every Programmer Should Learn
Most essential Java libraries you can learn to become a better Java developer. It includes Java libraries for logging…