Dept. of Computer Science and Engineering
Oregon Graduate Center
Software reuse is widely recognized as a key to improving both programmer productivity and the quality of software produced. However, software components found in existing libraries often cannot be reused because the algorithms they realize have been encoded in terms of particular implementations. An approach to reusability is presented where algorithms and implementations are specified separately. An algorithm is specified as a typed polymorphic function called a software template. Templates are defined over values of abstract data types whose implementations are specified separately and catalogued. When a template's data types are bound to catalogued implementations, the template is instantiated to a program component tailored to the chosen implementations. Different implementations of an algorithm can be achieved by merely rebinding the data types of its template specification to different catalogued implementations. There are four primary steps to instantiating a template. First, the template is transformed into tail-recursive form through the introduction of continuations. Implementation bindings for the template's data types are then propagated throughout the tail-recursive template by a type inference. Next, the tail-recursive template is translated into an intermediate, imperative-language code from which concrete code is generated in the final step. The result is a program component fully tailored to those implementations chosen to implement the abstract data types. Correctness of an instantiated template is established by separately verifying the correctness of the template and the implementations of its data types.
Volpano, Dennis M., "Software templates" (1986). Scholar Archive. 228.