5.4 Recipe for adapting the Separation construction principle

5.4 Recipe for adapting the Separation construction principle

Figure 5.5 shows the structure of the Separation construction principle and Table 5.4 describes the corresponding generic recipe.

Figure 5.5. The structure of the Separation construction principle
graphics/05fig05.gif

Table 5.4. Adaptation of a variation point based on the Separation construction principle
Recipe 'Generic adaptation for the Separation construction principle'
Intent The recipe describes how to adapt a variation point that is designed according to the Separation construction principle. Framework-specific considerations are not provided here.
Classes
  • Sep T marks the class with the template method, which is indirectly modified.

  • Sep H indicates the corresponding hook class/interface that has to be overridden/implemented.

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

Steps to Apply
  1. Understand the template hook relationship and the consequence of separating these methods.

    • Determine when and where in the template method Sep t the hook Sep h is used. Is the hook used 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 Sep T , in Sep H , or outside?

  2. How is the association between template and hook(s) established? Determine whether there is already a (sub)class of Sep H that provides the desired or a similar functionality. Could that be refined?

  3. If not, define a new (sub)class that inherits from Sep H , or that implements it in the case where it is an interface.

  • Implement the hook method in the newly defined subclass, indicated by the Sep h tag 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.

  1. Instantiate (i.e. create an instance of) the appropriate Sep H class and plug it into the Sep T instance for example, by invoking a defineH() method of a T object.

Discussion The Sep-H class may provide a default implementation for the hook method Sep-h that could be reused through super() calls. Comparing the Separation with the Unification construction principles, it is apparent that the Separation's ability to dynamically replace hook objects increases flexibility but also introduces some overhead (see Chapter 4).



The UML Profile for Framework Architectures
The UML Profile for Framework Architectures
ISBN: 0201675188
EAN: 2147483647
Year: 2000
Pages: 84

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net