hide all comments

DSM

Incremental language definition with an example - part 1

December 02, 2008 15:40:38 +0200 (EET)

Martin Fowler is writing a book on domain-specific languages and he introduces the topic with an imaginary example case: a company that makes systems controlling access to secret compartments.

He found the best to introduce readers to the domain by using graphical models. First, a sample system specification is illustrated and then, surprise, a metamodel of the language is shown. Later he describes several textual DSLs to specify the same system, but at least for me, easiest to read and understand was the one based on the graphical model.

I couldn’t resist and implemented the language and generators with MetaEdit+ too. I followed the usual steps:

  1. Defined the metamodel (as shown below)
  2. Draw the symbols for the notation
  3. Tested the language by specifying sample systems (see the system for Miss Grant)
  4. Implemented the generator(s)
  5. Tested the generators by comparing the generated code to available implementation

Metamodel

Now we can model various control access systems and generate the variable code using the common services provided by the framework. In fact with different generators we can produce all the different output styles or target languages (like this or this). You can download the language along with example models here and import it into your copy of MetaEdit+. Then you can start creating your own control systems like shown below - or modify the language and generators.

Model of the system for Miss Grant

Are we now ready? No, I don’t think so. While the editor and generators work they could be better. In the coming weeks I plan to refine this language and generators to illustrate alternative language creation solutions. Basically I follow what Fowler did when introducing different textual DSLs, but I’ll focus on graphical DSLs. I also try to discuss different language design decisions and their consequences to language use and evolution. Stay tuned.