Static and metaprogramming patterns and static frameworks: a catalog. an application

  • Authors:
  • Philipp Bachmann

  • Affiliations:
  • Institute for Medical Informatics and Biostatistics, Basel, BS Switzerland

  • Venue:
  • Proceedings of the 2006 conference on Pattern languages of programs
  • Year:
  • 2006

Quantified Score

Hi-index 0.00

Visualization

Abstract

The classic UNIX principle to write code that generates code instead of writing this code yourself [48, Chapters 1, 9] is experiencing a revival. Much research was done, the techniques are better understood now, and the generation tools were refined. This pattern catalog consists of adaptations of the Gang of Four design patterns [27] Abstract Factory, Adapter, Strategy, and Visitor to the metaprogramming level. It shows that replacing runtime polymorphism by static polymorphism helps to lift variation from the code level up to the meta level, where it might more naturally belong to. Some of the patterns proposed are especially useful for facilitating portable code. The patterns shown can be used to build static Frameworks [50]. A simple example is also presented. For all patterns proposed we identified usage examples in popular existing applications or libraries. Each pattern presentation is accompanied with an example. These examples show sample code in C++. The template metaprogramming capabilities of C++ [2, 17, 65] allow us to express both the program and the meta program in the same programming language.