Chapter 1: Software refactoring exercise

Preparation

face Josiah Wang Rob Chatley

This exercise will supplement my live lecture on software refactoring some time in the middle of the term.

I will assume that you have already attended/watched the live lecture, or already know what Template Method and Strategy Patterns are. So only go through the materials after I have talked about this.

Just like my live coding session in the lecture, you now have the chance to refactor some code using the Template Method Pattern and the Strategy Pattern.

Many thanks to Robert Chatley for allowing me to reuse this exercise from his Software Engineering Design course. I have adapted the code to Python and reworked it to suit my needs.

Do try this exercise yourself first and not just look at the solutions! Trying to refactor the code yourself is very different from just reading the solutions!