No single language can offer the primitive constructs needed to solve all conceivable problems. Therefore, programmers need to develop techniques or idioms to express interactions at a sufficiently abstract level.

Composition mechanisms

7

Additional keywords and phrases: weak delegation, exemplars, virtual constructors, multiple inheritance, the MVC paradigm, active values, propagation, constraint satisfaction
slide: Composition mechanisms

In this chapter, we will study a variety of composition mechanisms, including (multiple) inheritance, the definition of multiple roles by means of (weak) delegation, the use of callbacks and value propagation, and complex interaction schemes as embodied by the MVC-paradigm. Those composition mechanisms are not likely to be integrated at a language level, yet may become part of a framework supporting a methodical approach to software development if the consensus concerning their use is sufficiently well-established. The program fragments discussed in this chapter may be regarded as abstract schemas or (in the terminology of Coplien, 1992) idioms.  [Coplien92] provides a very rich source of material and ideas (indispensable to the serious C++ programmer), including the emulation of functional, symbolic and prototype-based programming styles in C++. In this chapter we will focus primarily on the various ways in which we may organize the interaction between objects. The interested reader is referred to  [Coplien92] to study the other idioms.