简体   繁体   English

将UML嵌入Java代码中最常用的方法是什么?

[英]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. 我试图将UML序列和类图添加到Java代码中,以解释其内部结构和设计概念。 I would like these diagrams to be specified in JavaDoc blocks and then converted into PNG/GIF images attached to API HTML. 我希望这些图在JavaDoc块中指定,然后转换为附加到API HTML的PNG / GIF图像。

What tool I can use for the automation of this process (I'm using Maven 3)? 我可以使用什么工具来自动化该过程(我正在使用Maven 3)?

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

I wrote a ant/maven plugin that uses javadoc to paint animations/images. 我编写了一个使用javadoc绘制动画/图像的ant / maven插件

在此处输入图片说明

I think that the model should be updated and not just diagrams converted to PNG/GIF etc.... Producing automatic diagram has no real value. 我认为应该更新模型,而不仅仅是将图转换为PNG / GIF等。...生成自动图没有实际价值。 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 ? 例如,在一个自动生成的图中显示巨大的类及其所有方法(例如有时超过100个)有什么好处? 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 !! 您可能会得到巨大的图表,却不明白为什么编写了此代码并且无法理解体系结构等。。。您只是看到了代码的图形视图,这不是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 show hide javadoc在我的UML类图中显示java doc

  • 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. 我认为JavaDoc中包含的自动图生成不是应该做的。 If you only spend 5 minutes manually, you would be able to update your existing model with all changes. 如果您仅手动花费5分钟,就可以使用所有更改来更新现有模型。 You would be able to create customize UML views in which you would be able to add comments. 您将能够创建自定义的UML视图,在其中可以添加注释。 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. 您可以做的是为每个开发人员提供一个UML查看器以及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. 您的UML模型可以与maven和SVN一起使用,并且确实为您的项目和建模带来了真正的价值,这是图像导出无法实现的。 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 在我看来,您尝试使用UML图只是为了将UML添加到您的项目中,但是添加了一个严重的反向项目的图像导出,该视图没有视图,注释等...不是UML,并且在Java项目中没有任何价值

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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