Upside down UML inheritance

Here's how inheritance is typically drawn in UML.



When the top two classes are in one package and the bottom class is in another package the effect is to create a package dependency pointing upwards (think of the inheritance triangle as a fat arrowhead). It's odd that this style for drawing inheritance is so dominant as it is in stark contrast to how package/layer dependencies are typically drawn - pointing downwards. The solution is simple - rotate the diagram!



However, associations are conventionally drawn left to right. Again the solution is simple - this time the diagram needs a reflection!



2 comments:

  1. I don't think it is necessarily odd that the convention for drawing inheritance is the other way up. In fact, if it followed the package layering convention that would be problematic. The natural reading of the abstract-at-the-top-concrete-to-the-bottom style deemphasises the concrete detail (which is what normally absorbs people's attention) and emphasises the interface perspective (which is normally overlooked).

    Is having two views a problem? Only if one view does not offer something the other doesn't. In this case I don't think there is a problem as I believe these have complementary emphases. There is a healthy tension between the two perspectives.

    ReplyDelete
  2. Yes odd is not the right word. Drawing abstract-at-the-top creates the impression that polymorphism works in a downward direction. That's fine of course. Package diagrams are typically drawn with the dependency arrows also pointing down the page. That's fine too. But these together might perhaps create a mental barrier? Could it possibly be one reason why code dependencies so often end up a mess?

    ReplyDelete