Alan Cameron Wills - Domain Specific Languages

Models, domain-specific languages, code generation, ....

The power of stereotypes

RobR > I think for many language definition purposes, UML stereotypes are in fact much more useful than you think.I think for many language definition purposes, UML stereotypes are in fact much more useful than you think.

My feeling is that it’s not exactly whether you can do it all in stereotypes, so much as (a) how hard it is; (b) whether your favorite tool will go all the way with you; (c) how much stuff you have to work around in the XMI, and bending the editors, etc. And as I said before, you may not want half the stuff you get with a UML editor. 

Let’s suppose in our language for designing baggage-handling systems, we have various attributes of conveyor belts: width, maxium loading, speed. Each of these comes in three possible values, and an airport might use belts with all 9 combinations for different purposes: <narrow, heavy-duty, fast>, <broad, light-duty, slow>, etc. Typically, our design staff tend to work by first of all, drawing the layout of the airport, with all the checkin desks and bins and junctions and carousels etc, and belts interconnecting them. Then they look more carefully at the projected loading of each belt, and assign values to the attributes — though these may change when they talk to the airport management. Because these are quite important characteristics of each belt, we want them to show up graphically: line thickness for belt width; hue for loading; and color saturation for speed. So once our designers get used to the code, they quickly recognise a thick deep scarlet as a broad heavy fast belt, while a thin sky blue is narrow and light and slow.

So here’s what I’d like to ask you, Rob. I’d like an editor that does this:

  • Line thickness and color change as the user edits the values of the corresponding association’s attributes.
  • I’d like the editor not to include extraneous stuff (like use-case and deployment diagrams) that would distract my airport software design people.

How would you do this in stereotypes? Is it easy to extend your solution if we extend the range of values for each attribute? Can you demonstrate a UML tool or two that will run your solution? How much processing would I need to do of the XMI that they produce?

(Thanks to my colleague Stuart Kent for prompting this example. I’m less of an expert in UML myself, but it’s significant to me that both Stuart and Steve are leading lights of the UML community. Stuart is chairing next year’s UML conference, for example.)