2009-02-11

What's new about Model-Driven Development?

The introduction of the Model Driven Architecture (MDA) by the Object Management Group (OMG) in 2001 caused a surge of optimism among the relatively few people still interested in code-generation. Finally a standard modelling language (UML) as a basis for code-generation, and consequently the possibility to exchange models between tools of different vendors! Since then the initial enthusiasm for the pure form of MDA has all but died away. Why? Primarily because UML proved less than ideal, in addition to being a modelling language, to serve as a basis for code-generation. Too complicated, too big, not semantically precise enough. And the standardisation proved more theory than practice. Vendors had to change UML in various ways to make code-generation possible, and of course each one did that in a different way. Goodbye interoperability!

But since a year or two the ideas returned in a slightly different and less ambitious guise: now based on Domain-Specific Languages (DSL's) instead of UML. DSL's are quickly getting very popular. Everywhere they are being experimented with, and new conferences about MDD are being organised every now and again.

I can think of at least three reasons for this: (1) DSL's are much smaller and more manageable than UML. (2) The appearance of tools like Microsoft's DSL Tools and openArchitectureWare (oAW) that bring development of DSL's within reach of ordinary developers. Interestingly, these tools are based on one or the other incarnation of the Meta Object Facility (MOF), the core of MDA. This meta-meta model standardises the development of meta models, the abstract forms of languages like UML and DSL's. (3) DSL's fill an urgent need. The complexity of the average JEE application is increasing so fast that few developers manage to keep up. At the back end of an application - the end nearest to the database - the problem is not yet so bad: Hibernate seems there to stay, whether or not as JPA-implementation. The Spring framework stands like a rock, even though it's growing faster than most of us can keep up. But at the front-end - the end nearest to the user - there is no clear winner among the many frameworks. The times that everyone used Struts are long gone. For each new application you have to make a choice between JSF, Wicket, GWT, Spring MVC or Web Flow, or a Rich Client, or many other widely used frameworks. It's simply too much for a regular guy who likes to watch a movie at night once in a while, instead of working through a tutorial (if there is one) of yet another new framework.

So MDD based on DSL's promises a solution for this chaos. You develop a DSL targeted at the domain for the application and a code generator where you can hide all the complexity. Of course for that you still need the rare geek that did manage to keep up with all the latest frameworks, but the rest of us just have to learn the simple DSL. And the geek can pour all his knowledge in the generator, so everyone is happy. So you would think.

Of course we have seen before how new developments promised a lot, but disappointed in the end. Object-orientation, aspect-orientation, agile development, test-driven development, whatever-driven development. So with MDD it will go likewise, probably. But most of these development have still brought some progress, only less revolutionary than we hoped. So the question is, what real progress will MDD bring?

Developing a DSL is hard. Not just the language, but the tools needed to work with it comfortably. So it would be nice if we could re-use it. Therefore the application architecture is often used as domain, instead of the domain of the user of the application. This was done with Mod4j for example. But in doing so the vision of the MDA - separation of business logic from platform specific implementation details - is only partly realised. We have to specify the application in terms of the application architecture, instead of concepts meaningful to the end user. We do make models, but since the appearance of tools like xText, we can develop textual concrete syntaxes as well as graphical ones. So what's the difference between a model and a program. Not much actually. Anneke Kleppe introduced the term mogram in her new book "Software Language Engineering: Creating Domain-Specific Languages Using Metamodels" to emphasise the practical equivalence of a model and a program in a DSL.

So what is new actually? Just this: that the developer works on a higher level of abstraction. For example, Mod4j generates nearly 25 lines of Java or XML code per line of DSL code. According to Frederick Brooke in his book "The Mythical Man Month", the productivity of a programmer is constant in terms of number of statements per unit of time. Real productivity data of DSL's in real projects are not yet available, so what the real gain will be is uncertain. But it certainly looks promising!