Tuesday, January 17, 2006

I am confused by OMG MOF 4 layers applied to MDSD and UML...

Today I tried to explain to some colleges the 4 layers of the OMG Meta-Object Facility (MOF). At first it sounds quite trivial:

  • Level M0: User Object Layer (Instances)
  • Level M1: Model (DSL – Domain Specific Language)
  • Level M2: Meta-Model (Schema description Language)
  • Level M3: Meta-Meta-Model (The Schema of the Schema)

Surprisingly applying the levels to concrete problems is not always obvious or straight forward.
I used the plugin.xml file as an example. I take here a MDSD centric approach, by assuming that the plugin.xml file "generates" the plugin....
  • Level M0: (Instance) The deployable component
  • Level M1: (Model) The plugin.xml file itself
  • Level M2: (Meta-Model) The extension point schema description (.exsd) files
  • Level M3: (Meta-Meta-Model) Schema of the .exsd files (implemented somehow in the .exsd editor)

Someone (a compiler person) asked me, how I would apply this to a programming language like C.
  • Level M0: (Instance) Executable code
  • Level M1: (Model) .C file (or a AST (Abstract Syntax Tree) representation)
  • Level M2: (Meta-Model) C language syntax definition (e.g. in yacc)
  • Level M3: (Meta-Meta-Model) Yacc language syntax definition

In this case, the meta model describes the constraints on the are AST (that's what the CDT does). This shows, that it makes sense to have a DSL (Domain Specific Language) at some levels. The DSL of C is simply the c syntax. The DSL of the c-syntax is yacc (or EBNF)... It is also interesting to have transformation between different representations of a model at the same level. C versus AST, yacc versus EBNF... The "code generation" happens between M1 and M0 (compiling). Another code generation happens between M2 and M1 when using a compiler-compiler like yacc.

But whenever I read about UML and MOF I get confused. This might have to do with the fact that I never really used UML....
  • Level M0: (Instance) Generated C/Ada code
  • Level M1: (Model) Concrete UML diagrams
  • Level M2: (Meta-Model) UML "language"
  • Level M3: (Meta-Meta-Model) ??

Again, a generator/transformer is applied between M1 and M0. Is this a correct application of MOF to UML?

But explaining both (the MDSD and the UML approach) to someone who has not been exposed to modeling gets very confusing.

So, in "my world" I prefer to see the MOF hierarchy very MDSD centric. I wonder if the MDSD centric view is confusing for UML experts is is the a natural way to see the world....


  1. * Level M0: Generated Classes
    * Level M1: UML2
    * Level M2: EMF
    * Level M3: ???

  2. How about:

    * M3 - MOF used to describe UML, e.g. EMF/ECore.
    * M2 - UML meta-model, e.g. UML2 plugin.
    * M1 - The users model, e.g. UML2 models and generated code.
    * M0 - The users model instantiated at runtime.

    Think of each layer as instantiations of the layer above. Traditional code generation is actually a model-to-model transformation that occurs at M1. Actually, the 4 layers are pretty useless other that to justify why the MOF (M3) exists. I've never used it in casual conversation ;)

  3. Doug, I have been using all kind of hand waving to explain model and schemes. That was the terminology I was using, and I have not even used it consistently. Probably because I have not had a clear picture in my mind. The MOF makes it easier for me to explain the concepts to people that have never really been exposed to modeling.... I found a nice citation: "In an n-level modeling architecture, M0, M1, ..., Mn-1, every element
    of an Mm-level model must be an instance-of exactly one element
    of an Mm+1-level model, for all 0≤ m < n-1, and any relationship
    other than the instance-of relationship between two elements X
    and Y implies that level(X) = level(Y)" (http://www.collabawue.de/dokumente/Gitzel-Hildenbrand-02-2005.pdf)

  4. Chris,

    * Level M0: Generated Classes
    * Level M1: UML2
    * Level M2: EMF
    * Level M3: SDO

    SDO is the next level for EMF.

  5. It seems an old post. However, I'd like to post my idea about UML mapping to MOF 4 layers.

    Yes, as Doug Schaefer said, the 4th layer is almost not used. So I think it is like this:
    Layer M0: UML model diagrams we drawed when we do modeling, e.g. e-bookshop class diagrams and use case diagrams. Actually it is the equivalent of C source file.
    Layer M1: UML meta model, e.g. model element specified in UML, class, interface, association, generalization,property,method, component and so on. It is the equivalent of C syntax.
    Layer M2: UML meta meta model, maybe its basic model elements is entity and relationship. It is the equivalent of syntax definition specification like EBNF.
    The basic thinking is think of each layer as instantiation of the layer above.