Friday, May 9, 2008

On Navigable Owned Ends...

OK, it’s time for me to get a little bit technical (and to try out JBuilder 2008) for a change. While working on the E/R metamodel as a member of the IMM submission team, I ran into an “interesting” scenario recently involving associations with one end type. Consider the class diagram below (the names have been changed to protect the innocent).


Can you see what’s wrong with this picture? The intent of the modeler was to express the fact that a bicycle has two wheels, one of which is the ‘front’ wheel (from the perspective of the rear) and one of which is the ‘rear’ wheel (from the perspective of the front). If you think about what an instance of this model might look like if it were mapped directly to classes and fields in a programming language like Java (using EMF, for example), you’ll realize that each instance of the 'BicycleWheel' class would need a reference to the bicycle’s other wheel, but also to itself – in order to satisfy the multiplicities (both association ends are required, i.e. they have a lower bound of 1), each wheel must reference both the front wheel and the rear wheel of the bicycle; obviously not a desirable result. In fact, it’s currently impossible to create a valid instance of this model using Java code generated by EMF, since an attempt to set a reference from the front wheel to itself (to satisfy the multiplicity) would result in its reference to the rear wheel being discarded.


What’s interesting (at least to a modeling geek like me) is that this redundancy could, in theory, be eliminated simply by making the association ends (the 'frontWheel' and 'rearWheel' properties) navigable owned ends. What does that mean? Well, in UML 2.x, it’s possible to designate a navigable association end as being owned either by the end type (as in the diagram above) or by the association itself. In the latter case, a mapping to Java would require a class to represent the association; now, in addition to there being an instance of the 'Bicycle' class and two instances of the 'BicycleWheel' class, there would be (at a minimum) an instance of the class representing the association which, in turn, would only need to reference each of the wheels once to satisfy the multiplicities. Ed and I have been giving some thought as to how owned association ends might be mapped to Java using EMF, but this special case makes me think that we still don’t have it quite right – see below.


I think there would still be an issue here with respect to navigability, because given a bicycle wheel, it's supposed to be possible to navigate to both the front wheel and the rear wheel (according to the model). Would this require redundant entries in the maps? What if a front wheel is passed as an argument to the 'getFrontWheel(BicycleWheel)' method? What if the owner of the bicycle rotates its wheels every season? I’m starting to wonder whether it should be considered valid at all to model a bidirectional association with required member ends and one end type. In the absence of an answer to that question and/or EMF support for mapping navigable owned ends to Java, there are a number of ways the model could be changed and still (or better) express the original intent. The model we ended up going with (or, rather, a reasonable facsimile thereof) is below. What might you have done differently?


Wednesday, May 7, 2008

On Change...

Embarcadero. It ain't just about databases anymore...

Friday, May 2, 2008

On the Efforts of the Few...

Dave has blogged a couple of times recently about his thoughts on standards development. As someone who is actively participating in the submission and revision of several specifications (some of which are standards) at the OMG, these comments certainly hit home. I agree that it’s typically 10% of the contributors that tend to do 90% of the work, and too often it seems that I’m among the “lucky” few...

One of the challenges of developing an OMG specification is the lack of tooling support for CMOF (Complete Meta Object Facility) models. This was one of the many topics that were discussed during the “Mega Modeling Mania” BoF (and again during the Eclipse/OMG Symposium) at EclipseCon in March. Based on those discussions, there does appear to be some demand for tooling that will make it easy to create, serialize (in CMOF-compliant XMI), and document metamodels that form the basis for open specifications. In response, I agreed to coordinate a proposal for a new component in the MDT project (tentatively dubbed “Metamodel Specification Tools”, or MST) to provide this kind of tooling at Eclipse.

The idea would be for the MST component to customize and/or extend the existing (or forthcoming) UML editors (primarily for class and package/profile diagrams) to expose CMOF concepts which are missing in UML (like identifiers, namespace URIs, and XMI tags), leverage the CMOF (de)serialization support that was introduced in the UML2 component as part of the Ganymede release, and provide a mechanism for generating a specification (or at least a decent boiler plate for one) directly from the metamodel using BIRT. Of course, it might also be desirable for the component to automate the mapping between a metamodel and its profile representation (if there is one) and possibly to make use of the Eclipse Process Framework (EPF) to document and coordinate the specification development process. If you’d be interested in contributing to such a component, I’d like to hear from you!