The UML Profile for Framework Architectures

5.3 Recipe for adapting the Unification construction principle

The Unification construction principle consists of one class marked as Unif-TH . It contains both the template method, marked as Unif-t , and the hook method, marked as Unif-h . Figure 5.4 shows the structure of this pattern and Table 5.3 describes the corresponding generic recipe. Though variation points based on the Unification construction principle are straightforward to adapt, the generic recipe serves as a checklist.

Figure 5.4. The structure of the Unification construction principle

Table 5.3. Adaptation of a variation point based on the Unification construction principle

Recipe 'Generic adaptation for the Unification construction principle'
Intent The recipe describes how to adapt a variation point that is designed according to the Unification construction principle. Framework-specific considerations are not provided here.
Classes
  • Unif-TH indicates the class that needs to be refined. No other framework classes are involved directly.

  • See Figure 5.4 for the UML-F class diagram.

Steps to Apply
  1. Understand the template/hook relationship ( Unif t , Unif h ).

    • Determine when and where in the template method the hook is invoked. Is the hook called more than once?

    • What is the hook method's responsibility, and how do changes affect the template?

    • Is the hook method used by another method in the Unif-TH class, or from outside?

  2. Determine whether there is already a subclass that provides the desired or a similar functionality. Could that be refined?

  3. If not, build a new subclass of the class marked by the UML-F tag Unif TH .

    • Implement the hook method in the newly defined subclass, indicated by the Unif-h tag by providing the desired functionality.

    • Determine whether you can reuse the provided default implementation through calling the inherited method. This is only possible if the inherited method is not abstract.

Discussion The Unification construction principle doesn't allow the hook implementation to change during runtime. The Unif TH base class may provide a default implementation for the Unif h() method.

Категории