A mapping rule that, for example, turns a UML attribute into transient data on the heap may not always be appropriate. In some cases, there may also be a need for persistent attributes, so we need to have two mapping rules and additional mapping inputs that select which rule to apply. These additional mapping inputs take the form of marks, which are lightweight, nonintrusive extensions to models that capture information required for model transformation without polluting those models. A mapping may use several different marks associated with the source models; conversely, a mark may cater to several different mappings. There also may be global marks that aren't necessarily related to individual model elements. However, marks mustn't be integrated into the source model, because they are specific to the mapping, and several different mapping rules may exist, each of which requires different marks. Integrating the marks with the model would make the model specific to the corresponding mapping rules, which isn't desirable. You can think of marks as a set of "sticky notes," attached to the elements of a source model, that direct the model transformer. You can use marks in two contexts: as additional inputs, which you can use to anticipate design decisions or reuse design decisions across mapping functions, and as additional outputs, which serve as a kind of record of the transformation process from a source model to a target model. A mark is defined by a marking model, which describes the structure and semantics of a set of types of marks. A mapping function specifies the marking models whose types of marks it requires on the instances of its source metamodels. If a mapping function can use more than one marking model for a single source metamodel, then one can reuse marking models for several different mapping functions. This, in turn, renders the corresponding marks reusable for different corresponding mappings. Figure 2-4 illustrates these concepts. Figure 2-4. Marks and marking modelsFigure 2-5 illustrates the idea that marking a model for different mappings leads to different platform-specific models (PSMs). Figure 2-5. From PIMs to PSMsThe source model for these mappings is a platform-independent model (PIM) with regard to the target platforms A and B. The marks don't pollute the PIM, which allows the PIM to be mapped repeatedly to two different PSMs. We explore PIMs and PSMs further in Chapter 4. Marks and marking models are discussed in detail in Chapter 6. |