Programming: MDA Overview

This article presents a little overview of the MDA concept (Model Driven Achitecture). Moreover, thoses few words are the base reflection that led me to the creation of XMITransform

Like all things found in this site, I wrote this small article with my very humble knownledge, so don’t hesitate to give me your feedback and / or advices.

Introduction : what is MDA ?

MDA stands for “Model Driven Application”. To make it simple, theses terms mean creating software architecture from a model (ie: an UML class diagram) instead of doing it from the source code.

Ok, now you can tell me “I always do some work in UML before starting to code”. In fact, MDA approach goes a little futher by generating the source code of your architecture. To be more precise, the goal of MDA is to convert a generic and plateform independant model (eg: UML) into a plateform dependant architecture (eg: php or java implementation).

For example, you do all your application modelisation into UML diagrams (use cases,  class diagrams, etc.). Then you choose what is the targeted plateform, and all the needed source code is generated.

The most used case is the UML class diagram to source code convertion (and vice-versa) . This is precisely the scope of this article (and the goal of XmiTransform)

However, don’t be fooled: MDA will not write the logic for you. We are only talking about architecture, that is to say skeleton of the application. MDA will write a method skeleton (name, parameters, documentations, etc.) but not the code of the method.

3 levels of MDA

My very own vision of MDA is the following: we can consider that MDA complexity and power is divided in 3 levels.

Level 1: write

This is the less complex level but also the less usefull. This does not means that this level is useless.

So this level is about transforming an UML model to sourcecode, plain, simple. I call it the write level because you can only write source code from the model. If you update the model you need to re-generate the source code and you loose, for example, any modification you made to the sources.

Despite you can think that this level is very limited, it can helps you a lot: generating code can save you hours of code writing and syntax errors corrections. Moreover, if your UML diagram is well documented, your source code will be well prepared to be completed by another developper with minimal efforts.

Level 2 : read (reverse)

The level two is a little more complexe than the first one. We can also call this level “the reverse level”.

Here, we are talking about reverse engineering of your code to build the Model. Like any automatic reverse engineering job, it can be more or less done correctly, but it lets you modify your code and re-create the model without loosing your changes. Another very usefull functionnality is to generate an UML diagram of an application to better understand its conception.

However, using this kind of functionnality will overwrite the model. And as I said earlier, automatic reverse engineering will never produce the same result as the original model that was used to create the source code.

Level 3 : Merge

Level 3 is the more complex and also (IMHO) the more usefull MDA level. We can call this level “the merge level”.

The purpose is to be able to write and merge source code from the model as well as read source code to produce and merge changes to the model. To make it simple: any modification done on the model is merged with the existing source code, and any modification of the source code will produce changes in the existing model.

The real power of the MDA approach is here: modifying the model while your are coding is possible without loosing your code changes. In the other hand, coding some part of the architecture will be translated in the model. Thus,  nothing is lost and constraints are minimals.

Existing solutions

There are differents available solutions: free, commercial, level 1, 2 or 3. As far as I know there are 2 kind of MDA softwares.

1 – integrated solutions

In general there are UML design softwares that allow you to transform your model into source code. The main limitations are:

  • you can only transform  your model to languages supported by the software
  • the generated source is abitrary formated (or at lesat, changing the format needs modifications of the software source code)

As example we can name Bouml, Rose, Enterprise Architect, etc. Note that theses sofwares sometime offers some source code reverse engineering to build the model from sources.

2 – Middleware solutions

What I call middleware are solutions that only offer the functionnality of transforming model to source and / or source to model  in an independant way.

Such solutions can be used thought their API by UML modeling software and programing IDE. Another way is to use standart file format (eg: xmi, which is UML explained in XML format).

In short: an middleware solution offer independant core functionnalities for transformation and allow you to write some plugins or drivers to modify the way things are generated. Thus you have more control at the price of a little more complicated way of doing.

As example we can name AndroMda or XmiTransform

My own middleware solution

Based on the above statements, I first tryied to use AdroMDA for a powerfull PHP code generation. But making  a generation module (this is called a cardrigde in androMDA language) is not that easy: it needs to read a big documentation, to follow a tutorial and write a dozen of java classes and velocity templates file.

So I decided to try to write my own solution. The final goal is to have a multi-language MDA middleware capable of merging (level 3).

As a first goal I tried to make code generation as easiest as possible keeping powerfull ablities. For now, XmiTransform is only capable of generating source code (level 2), but I think it is very simple to do so: you juste have to write one or more xsl file as well as a little xml file that organize your stylesheets.

You can check the project (XmiTransform) and even participate to it by giving me advices, remarks or help me in realization.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.