Template pattern with protocol-oriented programming

The template design pattern is a popular behavioral design pattern usually implemented with abstract classes. It helps design algorithms at a high level while letting subclasses or implementers modify or provide parts of it.

Protocol-oriented programming is particularly suited to implementing this pattern, as protocol extensions let you provide default implementations. Default implementations are perfect places to design and implement generic algorithms, as those algorithms can later be applied to a slew of concrete types.

To illustrate this design pattern, we'll build a simple recommendation engine that is tailored to the user's need.