Kata is a martial arts term from Japan that refers to a choreographed sequence of movements. The goal is to perfect and internalize these movements through repetition and memorization. Once mastered, these sequences serve as a reference guide that you can instantly reach for and adapt without thought.
Outside of martial arts, this word, kata, is used more generally to refer to any set of steps or patterns that is repeated until mastery. Think of it as a way to harness your form and routine.
Before we attempt our first coding kata, let's first take a moment to setup a base directory for our exercises. We'll use Composer to pull in PHPUnit and then register PSR-4 autoloading for the project.
First up is the prime factors Kata. A prime number is a number that is only divisible by itself and one (2, 3, 5, 7, 11...). Further, for any given number, we can generate its prime factors by reducing it down to exclusively prime numbers that, when multiplied, equal the number in question. In this lesson, we'll use TDD to create a class that can generate all prime factors for a number.
View the source code for this episode on GitHub.
Next up is the popular Roman numerals challenge. Our job is to create a class using TDD that can generate the corresponding Roman numeral for a provided number. To provide a few examples, 1 should return "I", 6 should return "VI", and 10 should return "X".
View the source code for this episode on GitHub.
I bet you didn't expect to learn the rules of Bowling on Laracasts, but here we are. In this lesson, we'll use TDD to record and score a completed bowling game.
View the source code for this episode on GitHub.
Next up is the string calculator kata. Our job is to create a class with a single public method that accepts a string of numbers to add. However, as part of the kata, a number of requirements must first be met, such as disallowing negative numbers and ignoring numbers greater than 1,000. Let's get started.
View the source code for this episode on GitHub.
Now that you've learned how to score a bowling game, let's move on to a Tennis match. This one is a bit more complicated, but well worth the effort.
Once you've completed the video, take a look at the source code to see how I solved the small homework challenge at the end of the video on GitHub.
Next up is the obligatory FizzBuzz kata, which I think you'll find is quite a bit easier than previous exercises. This is especially true, now that we've built up our TDD chops.
View the source code for this episode on GitHub.
*Series still in development. Check back often for updates.