S.A. 2008 domain specific modeling languages

This is the second in a two part blog-post about the software architecture 2008 conference in London. The two parts consist of:

  1. The conference itself, the conference location and software architecture in general.
  2. Building domain-specific modeling languages

At the pre-conference workshops Steven Kelly, co-author of the book Domain-Specific Modeling: Enabling Full Code Generation, showed the attendees what domain specific modeling is, what the value is, a general way of how to do domain-specific modeling and how to do domain specific modeling with MetaEdit+. To get a rough idea of the workshop check out this presentation. For more than one attendee with a Microsoft background the workshop was a bit of a surprise. The domain specific tools of Microsoft were mentioned and discussed a bit but not more than that. The company of Steven Kelly, called MetaCase, has been doing domain specific modeling for a long time with great success. They have been doing this without any influences from Microsoft and probably in the near future Microsoft will borrow more of their ideas. Stuart Kent was a MetaEdit+ user before moving to Microsoft, and they have thankfully borrowed at least some ideas, e.g. terminology and concepts like Relationship, Role and Object, rather than reinventing the wheel. Steven Kelly wishes they had borrowed more, e.g. a true concept of Graph, n-ary relationships etc.

In the past modeling has been used by Case Tools that generated code. These tools were seeking the silver bullet in code generation. These case tools were arguably not very successful. Isn’t domain specific modeling just another case tool ? The big difference is in the domain specific part, each modeling language is only intended for one company and one problem domain. This means its concepts can be at a high level and precise, rather than so low-level, generic or vague that they can be used to describe anything. Similarly the code generator is made by the customer to produce the same kind of code already used by them in their implementations, rather than having a vendor-provided generator with verbose and clunky “one size fits all” code.

What is domain-specific modeling ? It is modeling that:

  • Captures domain knowledge (as opposed to code)
    • Raise abstraction from implementation world
    • Applies familiar domain concepts and rules as modeling constructs
    • Narrows down the design space to focus on a single range of products
  • Lets developers design products using domain terms
    • Apply familiar technology
    • Solve the RIGHT problems
    • Solve problems only once! (directly in models, not again by writing code, round-trip etc.)

Or when you quote Wikipedia :

Domain-specific modeling (DSM) is a software engineering
methodology for designing and developing systems, most often IT systems such as computer software. It involves systematic use of a graphical domain-specific language (DSL) to represent the various facets of a system. DSM languages tend to support higher-level abstractions than General-purpose modeling languages, so they require less effort and fewer low-level details to specify a given system.

Why would you start domain specific modeling ?

  • Development becomes faster
  • Development becomes easier
  • Expertise can be leveraged
  • Routine tasks can be minimized

At the workshop Steven Kelly showed fifteen real life cases that he and his company worked on. And even when you don’t have all the details and because of that would only believe half, the numbers are still impressive. Below is a mix-up of several noticed benefits of those different cases.

  • Comparison to hand-written java after first thirty products = DSM is 3 times faster with fewer errors
  • Development time for a feature from a week to a day
  • Creation of new services 6 times faster compared to manual practices
  • Code generation produces 100% of implementation
  • Generate all required artifacts from a single design (code, configuration, documentation)
  • Look at the picture at the top right corner (Software Productivity Research & Capers Jones, 2002)

The general idea of how to build a domain specific modeling language is beyond the scope of this blog post. People who are interested are advised to get the book Domain-Specific Modeling: Enabling Full Code Generation.

During the workshop the participants were walked through and participated in creating a domain specific language for making interactive TV applications. This was done with MetaEdit+. MetaEdit+ is a very interesting piece of software.

Thinking up the domain experts concepts was the hard part. After that building the language and creating the generator and making a first model was very fast. One of the noticeable abilities was the ability to adjust the representation (while modeling) of parts of the model based on the relative positions of the parts programmatically. Is there a Microsoft product that is able to do this ?

A part of the way MetaEdit+ works is by the use of a domain framework. As a starting point, the code generated looks like the code the developers have written by hand so far. If large sections of that code are recognized as repetitive boilerplate, those multiple occurrences will initially be moved to be just one occurrence in the generator. However, if a section is more than a few lines it’s probably easiest to edit it outside the generator, so the IDE can offer syntax highlighting etc., so the repetitive code may well be moved into a separate function in its own file and just a call to that function will be left in the generator. Functions like that are what Steven Kelly calls the “domain framework”: new code components made by refactoring existing code during the process of creating the DSM solution. There’s not often much new code in the domain framework: code that already exists many times in hand-written apps, are taken and refactored so it appears just once.

When you want to use MetaEdit+ in an all Microsoft organization you have to keep some things in mind.

  • The user interface is not like most Microsoft products.
  • The generators are written in a language called MERL. Microsoft developers will need some time to get proficient with this language.
  • MetaEdit+ is a separate tool, not an add-in for Visual Studio. The generator can produce the code files and a new project file, or add them to an existing project. After some positive feedback from “Software Architect 2008” about a VS add-in, an add-in certainly has become a possibility.

But even when you take these points into consideration MetaEdit+ is definitely worth looking into

Great thanks goes out to Steven Kelly for commenting on and adding valuable context to this blog post. Hopefully he will not sue for plagiarism.