Improving Object-Oriented Generic Programming

Great efforts have gone into building scientific libraries dedicated to particular application domains and a main issue is to manage the large number of data types involved in a given domain. An ideal algorithm mplementation should be general: it should be written once and process data in an abstract way. Moreover, it should be efficient. For several years, some libraries have been using generic programming to address this problem. In this report, we present two major improvements of this paradigm. In generic libraries, a concept is the description of a set of requirements on a type that parameterizes an algorithm implementation (the notion of concept replaces the classical object-oriented notion of abstract class). A problem is that, until now, concepts are only defined in the documentation. We managed to make them explicit in the program by representing a concept by a type; moreover, (multiple) concept inheritance is fully supported. The procedure signature thus evolves from void foo( AbstractA& ) for classic object-orientation, and from template void foo( A& ) for classic generic programming, towards template void foo( ConceptA & ). This results in a better support of procedure overloading, which is of prime importance for libraries where each algorithm implementation can have numerous variations. Another problem is that the generic programming paradigm suffers from a lack of appropriate design patterns. We observed that classical patterns of Gamma et al. can be translated into this paradigm while handling operation polymorphism by parametric polymorphism. In these patterns, method calls can be solved statically, because the inferior type of each object in generic programming is known at compile-time. We thus preserve their modularity and reusability properties but we avoid the performance penalty due to their dynamic behavior, which is a critical issue in numerical computing. This results in better design capabilities for object-oriented generic libraries.

[1]  Ralph Johnson,et al.  design patterns elements of reusable object oriented software , 2019 .

[2]  Andrew C. Myers,et al.  Parameterized types for Java , 1997, POPL '97.

[3]  Lee R. Nackman,et al.  Scientific and Engineering C , 1995 .

[4]  James Crotinger,et al.  How templates enable high-performance scientific computing in C++ , 1999, Comput. Sci. Eng..

[5]  Matthew H. Austern Generic programming and the STL - using and extending the C++ standard template library , 1999, Addison-Wesley professional computing series.

[6]  簡聰富,et al.  物件導向軟體之架構(Object-Oriented Software Construction)探討 , 1989 .

[7]  Thierry Géraud,et al.  Obtaining genericity for image processing and pattern recognition algorithms , 2000, Proceedings 15th International Conference on Pattern Recognition. ICPR-2000.

[8]  Michael J. Vilot,et al.  Standard template library , 1996 .

[9]  Alexander A. Stepanov,et al.  Algorithm‐oriented generic libraries , 1994, Softw. Pract. Exp..

[10]  Martín Abadi,et al.  A Theory of Objects , 1996, Monographs in Computer Science.

[11]  Mehdi Jazayeri,et al.  Component Programming - a Fresh Look at Software Components , 1995, ESEC.

[12]  Thierry Géraud,et al.  Vers une réutilisabilité totale des algorithmes de traitement d'images , 1999 .

[13]  Luca Cardelli,et al.  On understanding types, data abstraction, and polymorphism , 1985, CSUR.

[14]  Todd L. Veldhuizen,et al.  Techniques for Scientific C , 1999 .

[15]  James O. Coplien,et al.  Curiously recurring template patterns , 1995 .

[16]  Bertrand Meyer,et al.  Eiffel: The Language , 1991 .

[17]  Alexander A. Stepanov,et al.  C++ Standard Template Library , 2000 .

[18]  Ullrich Köthe Requested Interface , 1997 .

[19]  Dennis Gannon,et al.  Active Libraries: Rethinking the roles of compilers and libraries , 1998, ArXiv.