Code katas provide an opportunity to practice our software development skills, recognize patterns, and learn how to apply practices. In general, we professional software engineers don’t spend enough time practicing. Code katas are one way we can practice. The Parrot Kata is based on a code sample in Martin Fowler’s Refactoring book. It is inspired by Monty Python’s Flying Circus Dead Parrot sketch.
The Parrot Kata introduces the Switch Statement smell as described by the Refactoring book. In this video, I describe the kata and demonstrate two refactorings (also defined in the Refactoring book) to remove the code smell. We’ll start with Replace Type Code with Subclasses to establish the class hierarchy infrastructure. Then we’ll move on to the Replace Conditional with Polymorphism refactoring to eliminate the Switch Statement code smell.
I use Java for this exercise but the Parrot Kata code repository has projects for many programming languages. If you like the video reach out to me and let me know. I plan on providing more coding content on my blog in the future.