Root elements in models
One of the best pieces of advice that I can offer the novice modeller is this:
Always have a "root" class that every other class in your model inherits from.
Often this class will be abstract, and often it will not have any properties or any associations. This may make you ask, why bother? My answer is this. It represents that the thing is within the universe of discourse of the model.
There seems to be a tradition of naming this class "XyzElement" where Xyz is the name of your model, but feel free to do as you please in this regard.
One of the main uses for this root class is to work with your model as the subject matter of some other model. For example, you might want to implement some kind of versioning system. In which case, you might like to link the versioning information onto your root class for inheritance into all your other classes. Or you might wish to have some association that relates things in your model to things in someone else model.
When I have ignored this golden rule, sooner or later I find myself going back and creating this root element, so save yourself the grief and do it from the outset.
0 Comments:
Post a Comment
<< Home