9.1 Transformations Definitions Revisited

What information do you need to generate a model from another model? You have to relate every element in the source model with one or more elements in the target model. The most direct way of doing this is to relate the metaclass of the element in the source with the metaclass of the element(s) in the target. Because of the instance-type relationship between model element and metaclass, every occurrence of the metaclass in the source will conform to the rules laid down for that metaclass.

Actually, the first transformation rules explained in Chapter 2, The MDA Framework, already used the metalevel, although in an informal way. Here they are again:

  • For each class named className in the PIM there is a class named className in the PSM.

  • For each public attribute named attributeName : Type of class className in the PIM the following attributes and operations are part of class of class className in the target model.

    • A private attribute with the same name : attributeName : Type

    • A public operation named with the attribute name preceded with "get" and the attribute type as return type: getAttributeName() : Type

    • A public operation named with the attribute name preceded with "set" and with the attribute as parameter and no return value: setAttributeName(att : Type)

The first rule refers to Class , which is an element of both the PIM and the PSM languages. In other words, the metamodel of those modeling languages includes the metaclass Class . The first rule also refers to an attribute className of the metaclass Class .

The second rule refers to a metaclass Attribute in the PIM. From the rule we can also infer that Attribute has the following (meta)attributes: attributeName, Type, and a (meta)attribute that can take the value public . We will name the latter attribute visibility. The metaclasses Class and Attribute live at the M2 level as we have seen in Figure 8-4. The metamodel of the PIM language therefore includes the metaclasses as shown in Figure 9-1.

Figure 9-1. The Class and Attribute metaclasses in the PIM language


About the metamodel of the PSM language, we deduce that it also contains a metaclass called Attribute, as shown in Figure 9-2, with two attributes of its own called attributeName and type . This metaclass has an attribute that can have the value private. Furthermore, from the second rule we can infer that the PSM language must include a metaclass Operation, with attributes name, parameter, return type, and visibility. The parameter has a name and a type and is therefore a metaclass itself. Because an operation may have a parameter, there must be an association between Operation and Parameter.

Figure 9-2. The metaclasses in the PSM language


In this example, the PSM and PIM languages are the same (both are UML); we have only one metamodel that we are referring to. Therefore, the enumeration VisibilityKind in the PIM language must be the same as the enumeration VisibilityKind in the PSM language. The enumeration VisibilityKind will have at least two possible values: public and private.

In practice we never deduce the metamodel of a language from descriptions as we have done above. Instead, the metamodels of the languages are either already available or we develop them separately before writing the transformation rules. This is the approach that we take from now on.

MDA Explained. The Model Driven Architecture(c) Practice and Promise 2003
Project Leadership (The Project Management Essential Library)
EAN: 2147483647
Year: 2004
Pages: 118

Similar book on Amazon

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