Using the strategy pattern

We have seen that the strategy pattern is a powerful design pattern that lets you dissociate algorithms from the objects they operate on. In our example, we could have implemented printing and description with the strategy pattern as well. Instead of implementing CustomStringConvertible with the strings directly, we could have also used a strategy that generates a string that describes the current bill.

With your implementations, you have to keep an eye on: