How can I simplify an UML class diagram inheritance notation?

╄→尐↘猪︶ㄣ 提交于 2019-12-13 00:51:25

问题


I have a super class, that 40 other clases inherit, at this point I would like to simplify the diagram, to be exact all the inheritance relations (40 relations point to a single class) all these "arrows" just make the diagram a complete mess, Is it posible to simplify this?


回答1:


There is no direct way to simplify such case in UML Specs, but really 40 classes to inherit from one class? I think you may need to re-consider your design again.

In general, you can omit attributes and methods from classes, that way is better at least.




回答2:


Are you using inheritance for code re-use? I have never encountered a scenario where there are 40 subclasses. Anyways, one idea is to group the logically related classes into 1 single package diagram and then have package relations.

I would like to offer few suggestions though

  1. UML diagrams are 90's ;-). In the current world of agile, I see little use of those diagrams
  2. Look into tools that can reverse engineer your code and create class and sequence diagrams when needed. This helps you to VISUALIZE only the relevant parts of an application ON-DEMAND
  3. Read about sub-typing versus sub-classing



回答3:


This is a good question because I had a similar problem in one of my projects. What I have done is to reduce the size of the each class in order just to have the name displayed. I have then selected a circular + hierarchical layouts and moved with my mouse all these links.

The result was brilliant. The tool I used was EclipseUML Omondo.




回答4:


I would suggest the following:

**

  • SCENARIO 1

**

If you do not plan on using the model for code generation:

  • Place all the subclasses into a package. Give this package a name to indicate that all it's contained elements / classes inherits from the specific super class. For instance, if the super class is named "SuperFoo", I would call the package "SuperFoo_SubTypes"
  • Place a note in the package to indicate that all the classes in the package inherits from the super class.

**

  • SCENARIO 2

**

You do indeed plan to generate code from your model:

Option 1 I would perhaps suggest that you draw all the inheritance associations as per normal, and then hide the super class using the hide functionality on your modelling tool.

Option 2 Use the alternative notation for describing inheritance/generalization by, for each of the subclasses, writing out the name of the superclass in italic font and in the top right-hand corners of the subclass elements. This method is briefly explained in this article: http://www.sparxsystems.com/resources/uml2_tutorial/uml2_classdiagram.html This will of course depend on whether your modelling tool supports this notation.

I hope this helps!



来源:https://stackoverflow.com/questions/4286949/how-can-i-simplify-an-uml-class-diagram-inheritance-notation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!