OptimalJ impressions tools 15649 6401

OptimalJ impressions

I recently attended a three-day training workshop for OptimalJ (the Architect Edition).
OptimalJ promises to provide a complete MDA solution, and this was my first
opportunity to get some hands-on experience and impressions of this

MDA basics

This is not an introduction to the concepts of MDA. For that I recommend the book MDA Explained by Anneke Kleppe, Jos Warmer, Wim Bast. But let’s for a moment review the basic concepts for the sake of clearity.


MDA, Model Driven Architecture, defines three kinds of models, in topdown order:

  • PIM = Platform Independent Model (example: domain model)
  • PSM = Platform Specific Model (example: Entity Beans).
  • code (examples: java sourcecode, EJB deployment descriptor)

Complementing this there are two types of transformations, PIM to
PSM, and PSM to code. By means of these, a PIM can be transformed to
code via one or multiple PSM’s. Typically, a PIM to PSM transformation
can be quite complex, while PSM to code is relatively simple and

transformations may be applied to the same PIM, resulting in serveral
PSM’s representing different implementation concerns, like persistence,
business logic, presentation and testing.

Building blocks

To implement MDA we need these building blocks:

  • Highlevel models (PIM and PSM).
  • A language to
    define these models (a meta-model). At present, UML with OCL (Object
    Constraint Language) is often the best option available.
  • PIM to PSM transformations.
  • A language to define these transformations. QVT (Query, View, Transformation) is the upcoming OMG standard.
  • Tools that execute the PIM to PSM transformation, preferably in a highly customizable fashion.
  • Tools that execute the PSM to code transformation.
  • Editors for models and transformations.

Note that many tools that claim to support MDA merely implement some
aspects of it, like some form of PSM to code transformation. JHeadstart is an example in case.


UML is a meta-model, it describes a
particular type of models: UML models. UML at large is best used for
structural aspects of a system, but less suitable for dynamical aspects.
our options don’t stop here. MOF, the Meta Object Facility, allows us
to create a custom meta-model, and make our own type of models. MOF
provides a framework for both defining a metamodel and querying and
manipulating the resulting models.

Now let’s see how OptimalJ handles MDA.

OptimalJ basics

As the name suggests, OptimalJ is geared towards Java projects (or it
would have been named Optimal.NET or similar). It should come as no
surprise that the ready-to-use transformations that come with it are
meant to generate 3-tier webapplications based on the EJB/Struts/JSP
technology stack that is almost old-school now.

My first MDA app

OptimalJ is build on top of the Netbeans application platform, and
looks sort of like a combination of an IDE and a UML casetool. To me,
this means the interface feels reasonably familiar and I have
no trouble getting started on the first exercises. A small domain model
is created as a UML diagram. From this PIM various PSM’s are generated,
and from these the code. Finally the code is packaged and deployed on a
testserver (an embedded JBoss). It doesn’t get any easier than this.

first app provides basic view and CRUD functionality. Easy as it was to
create this app, it is just as unlikely that it will ever satisfy all
requirements of a project. Let’s customize!


first option is to extend the functionality by adding a domain service
to the PIM. The domain service model can hold extra behavioural
information, like extra views, attributes or operations.

The next
level of customization targets the PSM’s. A number of these have been
generated from the PIM’s: presentation, persistence, business logic,
business facade and common data structures. Each of these can be
extended and enhanced to various effect, like adding business logic,
presentation logic, page flows and UI elements (webpages). This
requires a basic understanding of these models and various parts of
OptimalJ. Two days into the course barely got us started here. A host
of other OptimaJ wizards and tools were showcased for specific tasks,
like creation of a GUI, websercices, extracting a domain model from a
database, creating tests etc. We didn’t have enough time to cover all
of these in depth.

The code generation phase of the PSM to code
transformations can be customized as well. This is fairly easy and
straight-forward, and amounts to editing text templates. The templates
are defined using TPL, OptimalJ’s text templating language. TPL
templates merge model data with text and resemble JSP’s with custom
tags. Creating TPL’s requires a basic understanding of the TPL syntax
and the MOF API’s to query the model. It’s easier than it sounds.

Finally, parts of the generated code are marked as free blocks. Modifications of the code inside these blocks are preserved when the code is regenerated.

Advanced: roll your own

concept of MDA really shines when you consider the possibilities of
creating your own transformations and metamodels. Essentially this is
just another approach to software development, where all the knowledge
and best practices are captured in the models and transformations,
rather than being applied in handcoding of the results. Since the
generation process is repeatable, the (meta)models and transformations
can be developed in an iterative fashion. They can accomodate
everything needed to produce exactly the output we are looking for,
effectively eliminating the need for post-generation modifications.

course there is a downside to this: creating custom metamodels and
transformations is an arduous and timeconsuming task. It requires great
skills and intimate knowledge of OptimalJ, the various definition
languages used for its metamodels and transformations, the API’s, etc.
Evaluating  the feasibility of this scenario comes down to a number
game. The larger the number of repititions (e.g. the number of domain
objects), and the larger the value of consistency and reproducibility,
the more viable this approach is. But without further experience it’s
hard to tell where the threshold lies.


delivers on its promise to provide a complete MDA solutions. There may
be some rough edges, but all the components are there to support all
the MDA scenario’s one can think of. It comes with some pre-built
metamodels and transformations for immediate use, but these are of
limited value. Rolling your own is an option, but rather expensive.

seems to be going nowhere at present. I think this is largely due to
its lack of standardization, i.e. a standard transformation definition
language, a standard templating language and standard metamodels.
Progress is being made in these areas, but these issues will take a
while to be resolved. Once all the standards are in place, I expect to
see MDA really take off, at least in some areas. Until then it is a
very specialized approach that might be suitable for very specific


  1. David Herst February 14, 2006
  2. RJ de Vries February 2, 2006