Let us illustrate these problems with an example. Suppose we have built an image processing application that we would like to adapt to the special needs of an important customer. The existing body of func-tionality is large, so that we can not afford to throw it away and start over from scratch. To fill in the missing pieces quickly, we would like to reuse some functionality that has been developed in another context, perhaps another project or the public domain.
For example, suppose we want to incorporate the Shen-Castan edge detector that is part of the KHOROS system  into our environment. Unfortunately, this algorithm only runs on a specific variety of the KHOROS image format. If we do not happen to use this image for-mat in our system, we have an adaptation problem. This problem is traditionally solved in several ways:
Neither of these options is really satisfying. It would be much better if reusable components were provided as independent building blocks that do not depend on a specific environment (such as KHOROS) and can be adapted without knowledge of their inner workings (in particu-lar, without source code modification) and without loss of performance. The design methods described in previous chapters (Chapters 4 and 5) do not support independent building blocks very well, especially at the level of basic algorithms and data structures, where performance is at a premium. Therefore, in this chapter we describe an alternative de-sign approach called “generic programming,” which provides very good support for definition and flexible integration of independent building blocks. Generic programming complements the other methods so that we can design combined solutions (such as object-oriented frameworks delegating their implementation to generic components) that empha-size the strengths of each method.
The most important dependency we need to remove is the depen-dency of algorithms upon specific data representations. To a certain extent, object-oriented programming provides a solution to this prob-lem if data is accessed via abstract classes and virtual functions. An