I once saw two parrots. They might have been twins, yet again, maybe not.

12.1.05

abstract and inherited associations in MOF/UML

One of the best things to come out of the V2 of MOF/UML is abstract and inherited associations.

As a concrete example, lets consider the classes Driver and License. Now it's easy to imagine that these classes might be linked by an association Holds (as in Driver Holds License).

Now, we might have a number of subclasses of Driver, such as CarDriver, TruckDriver, etc. And some corresponding subclasses such as CarLicense, TruckLicense, etc. Now the intention here is that CarDrivers Hold CarLicences and that TruckDrivers Hold TruckLicenses.

Back in the bad old days of MOF/UML v1, there was no easy way to express this intention. The association was between Driver and Licence and hence it was perfectly OK for CarDrivers to hold any kind of License. The only way to prevent it was to introduce an explicit Constraint which enumerated all the allowable combinations.

The alternative was to introduce a number of separate associations between CarDriver and CarLicense (call it CarHolds) , and TruckDriver and TruckLicense (call it TruckHolds), and so on. But the drawback here is that the general concept of drivers holding licenses is lost in the fallout. The only way to recover it is to introduce a derived assocation between Driver and License and define it to be the union of the CarHolds and TruckHolds and so on.

Fast forward to having abstract and inherited associations. Now, we can make the Hold association between Driver and License abstract, and then we can have an inherited concrete association between CarDriver and CarLicense, and another one between TruckDriver and TruckLicense and so on. This implicitly restricts CarDrivers to holding CarLicenses, but still also us to talk about holding a license in a general sense.

Admittedly you still have to define all of these associations, but because of the inheritance relationship, the model as a whole becomes a lot more scaleable. It becomes possible to define the model just consisting of high-level classes and high-level associations and then refine parts of the model progressively. This helps the documentation of the model, particularly if you are using graphical representations of your model.

You will find using abstract/inherited associations does alter your modelling style, and that it does involve a bit of a paradigm shift when you are modelling. But try it and see, I think your models will be more readable and more modular.

2 Comments:

Blogger Jim said...

Kerry, what is tool support like for this?

6:19 pm

 
Blogger Mike P. said...

Hi,

Thank you for wonderful blog. I came upon your blog as I was searching for paypal complaints. The funy thing is that every time I encounter palpal complaints I also saw references to America's Servicing Company.

Can you please explain this to me?

Regards,

12:34 pm

 

Post a Comment

<< Home