Platform Independent Models, Platform Dependent Models, and Code Generation

, Feb 8, 2004

I got into a very interesting discussion a few days ago: Where exactly can you find a PIM and a PSM in both in the MDA vision as such as well as in existing tools such as iQgen. My view on this issue is:

In MDA:

  • A Platform Independent Model (PIM) is the starting point.
  • The PIM is turned into a Platform Specific Model (PSM) by means of a transformation. This can be done either manually or automatically.
  • The PSM can be transformed again, yielding an even more platform specific model - other words, a new PSM, targeting another platform.
  • The final PSM is turned into code.

In “Pragmatic MDA” or “MDA light” or “MDA as it exists today” …

  • A Platform Independent Model (PIM) is the starting point, although it might be called a PSM with some justification (as it will usually contain at least information to target an “abstract” platform)
  • The PIM is turned into code by means of an automatic transformation.

So is there a PSM in the second approach? If so, where?

In my opinion, the PSM, if you insist on finding it, is the code itself. How can the code be a model? A model, in general, is a simulation of some concept or aspect from a specific point of view, intended to enable reasoning about it for a particular purpose. If I take the resulting code in the second approach from above, I can look at it in an IDE, the purpose being to edit in its textual form. If I read the same code into a 1:1 CASE tool such as Together, I see a visual rendering; the purpose of which might be to manipulate it visually or explain it to somebody else.

On February 10, 2004 2:49 PM, Hendrik Schreiber said:

I disagree with the statament that the PSM is the code. The OMG defines Model and Implementation like this (http://www.omg.org/docs/omg/03-06-01.pdf):

2.2.2 Model A model of a system is a description or specification of that system and its environment for some certain purpose. A model is often presented as a combination of drawings and text. The text may be in a modeling language or in a natural language.

2.2.17 Implementation An implementation is a specification, which provides all the information needed to construct a system and to put it into operation.

To me this implies that - yes - code could be seen as a model. But it would be a very degenerated model, as it is identical with the implementation. A good model is hardly ever identical with the implementation, as it is supposed to make things easier to understand and illustrate ‘certain’ aspects of a system, not ‘all’ of them.

When you look at the code in Together you certainly see a model, not the code, as the model is derived from the code. But that’s not the same. Therefore it is a weak argument to say: “Hey, the PSM is the code, as I can derive a model from it.”

Following that line of thought would mean that a smart enough CASE tool could let you view a PIM derived from source code and you could say: “Hey, the PIM is the code, as I can derive the PIM from the code.” You got to admit: PIM == Code - that’s a little too far fetched, right?

When transforming from PIM to implementation you are implicitly using some kind of PSM. Otherwise the code could not be executed as it would not fit the platform. As the vehicle for transforming the PIM to an implmentation is usually a set of templates, the PSM must be implicitly contained in those templates.

An example:

If you define a stereotype Entity in your PIM and you create a J2EE EntityBean from it through your templates, the templates carry the information that an Entity becomes an EntityBean on the platform the templates were written for. This is typically the same information that makes a PSM. Therefore I believe that the templates implicitly contain the PSM.

In the end it does not matter where the PSM is. No one has ever written a better system, because he knew where the PSM was. Maybe this should make us think about whether a PSM is relevant in todays MDA approaches at all. Sure it would be nice to be able to just apply some transformation to a PSM or PIM to generate a PSM for another platform. But reality is, that you would still have to write a whole new set of templates for that platform. So why not start with templates in the first place and leave out the PSM.

Just some thoughts…

On February 12, 2004 7:51 PM, Stefan Tilkov said:

This is a more of philosophical discussion, so maybe we should avoid it ;-) But I can’t see much difference between translating from C Code to Assembler and from a model represented in XMI to Java Code. The code is a model of something, represented in a form so that a specific tool (the compiler) can use it. The XMI is just another representation, targeted for another tool (the CASE tool or generator).