November 2017
Intermediate to advanced
386 pages
9h 22m
English
The Strategy pattern applies whenever you want to have the ability to change a class, method, or function, possibly in a dynamic way, by changing the way it does its thing. For example, a GPS application might want to find a route between two places, but applying different strategies if the person is on foot, rides a bicycle, or goes by car. In that case, the fastest or the shortest routes might be desired. The problem is the same, but different algorithms must be applied, depending on the given condition.
By the way, does this sound familiar? If so, it is because we have already met a similar problem. When we wanted to sort a set of strings in different ways, in Chapter 3, Starting Out with Functions - A Core ...
Read now
Unlock full access