Overview

What is Medea?

Medea is a tool that uses XSLT to generate code from UML models. A system described in a platform-independent UML model is taken as the input to various "templates" that transform the model into software artifacts such as source files, deployment descriptors, SQL scripts or web pages. These artifacts can be compiled into classes, components, application layers and complete executable applications.

Medea attempts to implement Executable MDA (Model Driven Architecture) paradigm where a correctly modeled system can be transformed into working software components and applications.

Goal: MDA simplified

Why another MDA tool? MDA has been around for a while and proved to work. Popular tools exist, ranging from complete modeling solutions costing thousands of dollars to open-source projects. However, all tools to date have several deficiencies that complicate the MDA process:

  • Language. Most of existing code generation tools introduce their own template language and markups. Some adapt existing languages such as JSP. However, there's still no solution that would use a well-known and platform neutral language.
  • Learning curve. Existing tools introduce their own approach to parsing the UML model and generation. These approaches often seem over-architected. There are "meta-models", plugins, profiles, libraries, proprietary parsers, etc. Each tool requires a significant investment of time to learn its architecture.
  • Bloat and cost. Many tools offer modeling capabilities and complicated generation tools. As a result, these packages are unnecessarily bloated and costly. Other popular UML modeling applications such as Rational Rose, Poseidon, MagicDraw do the modeling job better.
  • Vendor lock-in. Code generation is often hidden from the developer into vendor-supplied templates or code snippets. Many solutions generate working applications behind the scenes, from database schemas and UML models. They may be suitable for novices or prototyping but not for a serious project.
  • Technology lock-in. Most of existing tools are geared toward a specific programming language, technology or platform.

Medea simplifies the MDA process by taking a down-to-Earth approach. It does not introduce any new language, markup, or libraries (in fact, the core Medea distribution does not contain any binary code). It is a collection of transformation templates written in a standard language and applied by standard tools.

Solution: XSLT templates

Let's see what's really happening when a model is transformed into a working application. A UML model can be exported as an XMI file - all leading modeling tools support this. The XMI file is clearly defined and completely describes the model. We then transform this file into text artifacts: code, scripts, descriptors etc. The transformation is defined by a template produced by a software architect. The template must be easy to read and maintain, preferably in a single text file independent of a product or an IDE. So in the end it's just an XML to text transformation.

An obvious choice for this transformation is XSLT - an established and well-known language. As long as a modeling tool can export the model as an XMI file, a collection of XSLT templates can transform it into source code which is compiled into components. This is what Medea really is: a collection of XSLT templates.

Challenges

  • Elements of the model must be easily accessed and traversed by a template developer. Model elements must be as easily identified in a template as they are in a graphical model. All XMI specific code and XPath queries must be hidden.
  • XMI format is complex and far more detailed than needed for code generation.
  • Modeling tools export XMI in several different formats.

XSLT functions library

Thanks to the introduction of functions in XSLT 2.0, these challenges can be addressed by moving these tasks into XPath queries and functions. At the core of Medea is a library of XSLT functions that hide the complications of working with the XMI format and give the template developer a clean and clear API to:

  • Access model elements.
  • Access elements' attributes and methods.
  • Access elements' relationships and dependencies.
  • Traverse object hierarchy.
  • Simplify common tasks.

Armed with this library, a software architect with very basic knowledge of XSLT can produce any number of code generation templates. The learning curve consists of learning a few XSLT statements and a few API functions.

Result: pragmatic and simple MDA

We tried to develop an MDA tool by avoiding the unnecessary functionality, sticking to well-known languages, platform-neutral technologies and altogether keeping it very simple. As a result:

  • Medea is independent of a platform or a programming language.
  • The learning curve is minimal.
  • Medea uses a well-known language designed specifically for transformations. While very small subset of XSLT is required, you can use other powerful features and built-in functions.
  • Simple design lets you concentrate on your own system's architecture.
  • Medea does not require a GUI. The templates can be edited in any text editor and transformations performed by a third party tool.
  • Use and extend a library of XSLT functions. Write your own templates for any platform or use existing templates that cover various technologies.