Publication: C++ Builder Developer's Journal Issue: Volume 9, Number 8, August 2005
The strategy pattern is one of the most commonly used coding designs that I employ. A simple pattern to implement it's design is to encapsulate related algorithms and make them interchangeable. Ever built a website that was littered with conditional statements on a page to determine if something should be displayed? If you have the same conditional statement written more than 3 times then you should look at the strategy pattern where you would only need to write that conditional once.
The purpose of the Strategy design pattern is to encapsulate a family of related algorithms that perform the same task, and make them interchangeable. There could be any number of reasons why this would be necessary, and this article will demonstrate the use of the Strategy pattern with the TSTLStringList and TVCLStringList objects acting as the interchangeable algorithms.