Code Katas, why, what, and how?
Code katas are like fun challenges for programmers, similar to practice routines in martial arts. They’re designed to help developers refine and perfect their coding skills through repetition and practice. These tasks focus on writing neat and fast code. Usually, developers follow a method called Test-Driven Development (TDD). They start by writing a test that should fail, then write the code to make it pass, and finally make the code better by refactoring. This kind of practice helps programmers improve their skills, understand TDD and their coding tools better, so that they can confidently use them in real projects. Read more about Code kata from Dave Thomas.
In a nutshell, the following are the reasons, you do code kata.
- Improving Coding Skills: Code katas help programmers refine their coding abilities through repetition and practice.
- Learning Clean Coding Practices: By tackling small coding challenges, programmers learn how to write clean, efficient code.
- Understanding Test-Driven Development (TDD): Code katas often follow the TDD approach, which helps programmers understand and implement it effectively.
- Enhancing Problem-Solving Skills: Working on diverse coding challenges in katas strengthens a programmer’s problem-solving skills.
- Gaining Familiarity with Coding Tools: Regular practice with code katas helps programmers become more comfortable and proficient with their coding tools and libraries.
How to do a code kata?
To conduct a code kata effectively, start by selecting a coding challenge or problem that aligns with the skill level and goals of the participants. I choose something easy, that encourages the beginners to participate and have fun rather than get scared. Once the participants are used to the setting and the process, you can increase the difficulty gradually.
Provide clear instructions and constraints for the kata to ensure focus and productivity. Provide as much instruction as necessary. Create a written document, a README.md file in a repository. Go through it during the session. Do not skip any bit, or hurry. Make sure everything is understood by your participants.
Encourage participants to follow the Test-Driven Development (TDD) approach by beginning with a failing test, then writing code to pass the test, and finally refactoring the code for improvement. Go through the basics of TDD in case there are participants who are not familiar with the approach. Do a short demo of a TDD iteration if need be.
Set a time limit for each iteration to maintain momentum and prevent overthinking. For instance, we typically conduct two rounds of 20 minutes each, pairing participants like rally racing teammates: one drives, while the other navigates. The driver takes control of the code editor, actively writing code, while the navigator’s role is to guide, offering ideas, logic, and time awareness to keep the team focused on the task at hand and prevent distraction from the main objective.”
Foster a collaborative and supportive environment where participants can learn from each other’s approaches and experiences. After the end of the two rounds, allow participants to share their solutions and approaches, so everyone can learn from each other.
After completing the kata, gather feedback from participants to identify areas for improvement and tailor future katas accordingly.
If you are looking for a team to actively do code katas, join my discord server
Kata challenges
I have developed a few challenges for code katas. Feel free to use them, and feedback is always welcome.
1. Minesweeper Github
Minesweeper is a game in which, the goal is to find all the mines within a field.
To help the user, the game shows a number in a square which tells you how many mines there are adjacent to that square. Read more >
2. Fill the grid Github
Fill the grid with blocks
- There is a 2D grid of any given dimension, you need to fill it in with blocks that user input.
- The user can input 2D blocks of any dimensions
- The input blocks need to be placed from left to right and top to bottom.
I will be updating the Github repo with more challenges in the future. I hope you found this post interesting.