Why I enjoy coding Kata's
Created at 2020-08-05 Updated at 2020-10-05 Category Kata
One of the things that have helped me to learn software development using PHP is coding Katas. I especially enjoyed the Katas by Emily Bache on Github. They offer a safe sandbox environment to play with code and tools. They have good, or should that be not so good, starting code to self teach techniques for refactoring, testing and object orientated code.
In fact, I enjoyed them so much, I have contributed to them! I have helped standardised the PHP versions to PHP 7.2+, with consistent documentation on how to start. I would highly recommend them to anyone interested in improving their skills and knowledge.
PHP tooling has also been standardised for many of the PHP codebase:
- Composer for PSR-4 autoloader and managing dependencies
- PHPUnit for testing
- Easy coding standard (ECS) for PSR-12 coding standard (plus other helpers)
- PhpStan for static analysis.
These tools can be used to practice and learn too, they are all configured and ready to go. They can be used as much or as little as required. ECS and PhpStan are particularly useful for the Kata’s which need code to be refactored, these should be considered as tools which help the coder, keep a consistent standard and help identify bugs. These tools can be removed and replace with other coding standard and static analysis tools are preferred.
The Kata’s are to a high PHP7.2+ PSR-12 standard, except the code which needs refactoring, with namespaces, PSR-4 autoloader etc. They also have consistent documentation with how to download and start using composer.
Kata’s which are configured for PHP:
- Gilded Rose Refactoring Kata - Practice writing tests, refactoring code and adding a new feature.
- Parrot Refactoring Kata - Practice refactoring and Pol(l)ymorphism
- The Supermarket Receipt Refactoring Kata - Build automated tests for this code, refactor it, and add a new feature.
- Racing Car Katas - Practice testing and refactoring using SOLID principles.
- Tennis Refactoring Kata - Practice refactoring and feedback.
- Theatrical Players Refactoring Kata - Based on the first (free) chapter of ‘Refactoring’ by Martin Fowler, the 2nd Edition
- Lift Kata - Use approval testing approach to implement a lift system.
I hope others will find them useful, as I have.