简体   繁体   中英

What is most common way to embed UML into Java code?

I'm trying to add UML sequence and class diagrams to my Java code, in order to explain its internals and design concepts. I would like these diagrams to be specified in JavaDoc blocks and then converted into PNG/GIF images attached to API HTML.

What tool I can use for the automation of this process (I'm using Maven 3)?

Javadocs中的UML图 :本文显示了在Javadoc中包含UML图并随源代码存储库中的每次更改进行更新的过程是多么容易和简单。

I wrote a ant/maven plugin that uses javadoc to paint animations/images.

在此处输入图片说明

I think that the model should be updated and not just diagrams converted to PNG/GIF etc.... Producing automatic diagram has no real value. What is the interest of for example showing a huge class and all its methods (eg sometimes over 100) in a single automatically generated diagram ? You could get huge diagram and not understand why this code has been written and could not understand the architecture etc...You just see a graphical view of your code which is not the goal of UML !!

What I do in my projects for my code is to use following features:

  • The show hide javadoc display java doc in my UML class diagram

  • I also use the reverse of a method in order to get a sequence diagram.

  • What I appreciate the most is to be able to live navigation in the code and then extract my model and only navigate in the model. I can model whatever I want and try new architectures before giving it the developer team.

I think that automatic diagram generation to be included in the JavaDoc is not what should be done. If you only spend 5 minutes manually, you would be able to update your existing model with all changes. You would be able to create customize UML views in which you would be able to add comments. Having views will provide better information to the team while saving time and adding quality to the code.

What you can do is to provide an UML viewer for each developer and a link in your JavaDoc. The developer will only need to click on the link and would be able to open the diagram which would be automatically update. No more painful image export, wrong update because once the image has been created it is impossible to change it. You can still create new images but you loose your comments, presentation etc..... and only get a static huge diagram including all methods, attributes etc...not being able to detect advanced association and dependencies. Only inheritances detection is correct !!

You UML model could be used with maven and SVN and really bring real value to your project and modelling which can not be achieved by image export. It seems to me you try to use UML diagrams just in order to add UML to your project but adding image export of a badly reverse project without views, comments etc...is not UML and has no value in a Java project

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM