March 2002
Intermediate to advanced
496 pages
8h 51m
English
An ancient example of TEMPLATE METHOD that is not only pre-Java but also prehistoric occurs in sorting.[1] Sorting has various algorithms, but in most settings, you can establish a single algorithm and use it to sort various collections of objects. Any algorithm that you use for sorting will rely on the primitive step of comparing two items, or attributes. If you can compare, say, the sharpness of two arrowheads, your sorting algorithm will let you sort the arrowheads in a collection.
[1] Some developers think of sorting as an example of STRATEGY. Challenge 23.6 on page 247 will ask you to compare STRATEGY and TEMPLATE METHOD.
In recent times, sorting probably reigns as the most frequently reimplemented ...
Read now
Unlock full access