This is a more advanced HPC optimization, that can only be done from languages that supports OO recasting, or calling function pointers. It is useful to replace lenghty switch or if-else if conditions. Or even non so lenghty ones when dealing with an often invoked portion of code.

It is easiest to accomplish in C# or Java, so will explain it from the C# point of view.

After identifying code of this nature that is a performance problem, or may become one, the idea is to reorganize into a set of objects sharing the same base object, with a common abstract method name, the build a collection of these into a dictionary with a lookup key (Uses B-Tree algorithym).

For this example, say you are dealing with code that needs to format adresses for display or printing differently for specific contries. The if-else if for this can be reorganized into objects then a dictionary with the following techique.

Definine your base object as a static abstract, with a static abstract method that will be common for all child objects. For this senerio abstract class AddressHandler abstract method String FormatAdress(type field1, ...., type field#).

Then define your static objects that will implement static FormatAddress and parse the fields into a countries specific format. class USAAddress, class CanadaAddress, ..., class UKAddress

In the code that will be using these, define a dictionary object with a lookup key of the contry code, and the formater for that code as the return type, using the base abstract class type as follows. I usualy define these types of dictionaries in a class library and the objects it uses, for reuse in main code.

        Dictionary<string, AddressHandler> AddrFormatList = new Dictionary<string, AddressHandler>()
                {"USA", (AddressHandler)USAAddress},
                {"CA", (AddressHandler)CanadaAddress},
                {"UK", (AddressHandler)UKAddress}
Then replace the long if-else if switching with just a few lines of code where needed.

        AddressHandler Address = AddrFormatList.Item(CountryCode);
        String FormattedAddress = Address.FormattAddress(field1, ..., field#);
The end result of this, is a significat increase in performance, as instead of going through a long list of condition in a switch like construct, in a serial manner, the specific code is found for a country, by a b-tree search on the dictionary. The longer the switch like construct is the more benefit you get from this technique.

However, this also is a case there the optimization, is also more maintainable, in that if you have to change one contries address format, you just alter that object, and don't have to search though a huge switch like construct for it.

Additionaly in the code that uses this, you've eleminated sometimes hundreds of lines of code, with just two. Making it much more readable for others coming after you that need to maintain it.