Summary
In this chapter, we covered the Template design pattern. We use Template to eliminate redundant code when implementing algorithms with structural similarities. The code duplication elimination happens using action/hook methods/functions, which are first-class citizens in Python. We saw an actual example of code refactoring using the Template pattern with the BFS and DFS algorithms.
We saw how the daily routine of a worker resembles the Template pattern. We also mentioned two examples of how Python uses Template in its libraries. General use cases of when to use Template were also mentioned.
We concluded the chapter by implementing a banner generator, which uses a Template function to implement custom text styles.
This is the end of this book. I hope you enjoyed it. Before I leave you, I want to remind you about something by quoting Alex Martelli, an important Python contributor, who says, "Design patterns are discovered, not invented" [j.mp/templatemart, page 25].