I worked through one of Dave Thomas’s programming exercises, called a kata, and pushed my Swift 2.2 code to GitHub. The code shows how to apply the Don’t Repeat Yourself (DRY) principle to two similar but different data processing programs.
The end result of this exercise is a satisfyingly readable higher-order function, which is similar to a template method but does not require subclassing to supply context-specific logic.
Here is the kata:
And here is my implementation of the kata’s third challenge:
This was a great learning experience!