java 如何从现有代码生成类图和序列图?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15583930/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 20:09:06  来源:igfitidea点击:

How to generate class diagrams and sequence diagrams from existing code?

javanetbeansreverse-engineeringclass-diagramsequence-diagram

提问by Lemon Juice

I have a Java code which I need to generate the class diagrams and sequence diagrams. I am using netbeans, but the code is 100% pure hand coded. How can I generate the class diagrams and sequence diagrams for existing code using netbeans?

我有一个 Java 代码,我需要用它来生成类图和序列图。我正在使用 netbeans,但代码是 100% 纯手工编码的。如何使用 netbeans 为现有代码生成类图和序列图?

The code is separated into packages, so I need to generate class diagrams package wise. Which means, for an example, diagram 1 for package 1, diagram 2 for package 2 etc. Finally I need to take the generated GUI as an image.

代码被分成包,所以我需要明智地生成类图。这意味着,例如,包 1 的图 1,包 2 的图 2 等。最后我需要将生成的 GUI 作为图像。

Please help!

请帮忙!

采纳答案by Stephen C

IMO, generating UML diagrams for code that you have written yourself is kind of pointless. The value of UML is as a design aid and to a lesser extent as a reverse engineering aid. If you are intent on generating code documentation for existing well-understood code, Javadoc is probably better value than UML, and a lot less work.

IMO,为您自己编写的代码生成 UML 图是毫无意义的。UML 的价值是作为一种设计辅助,在较小程度上作为逆向工程辅助。如果您打算为现有的易于理解的代码生成代码文档,Javadoc 可能比 UML 更有价值,而且工作量要少得多。

The other problem is that generated UML class diagrams tend to be ugly because they tend to include more detail than is necessary, and because you need a human eye to lay things out decently. The same probably goes for sequence diagrams.

另一个问题是生成的 UML 类图往往很难看,因为它们往往包含比必要更多的细节,并且因为您需要人眼来合理地布置事物。序列图可能也是如此。

But if that hasn't convinced you, these links should help you do it.

但是,如果这还不能说服您,这些链接应该可以帮助您做到这一点。

(Disclaimer: scraped from this closed Question - UML automated generation for Netbeans 7.1)

(免责声明:从这个封闭问题中摘取- Netbeans 7.1 的 UML 自动生成

Finally I need to take the generated GUI as an image.

最后我需要将生成的 GUI 作为图像。

Take a screen shot of the GUI using the tools provided by your OS.

使用操作系统提供的工具截取 GUI 的屏幕截图。

回答by rockstar

I just created UML diagrams for my uni project . Sad to see that Netbeans has stopped supporting UML plugin for its newer versions. In case you are also on a newer version like me (7.3 ) then you can make use of a third party tool namely yWorks UML Doclet to generate UML .

我刚刚为我的 uni 项目创建了 UML 图。遗憾的是,Netbeans 已停止支持其较新版本的 UML 插件。如果您也像我一样使用较新的版本 (7.3),那么您可以使用第三方工具,即 yWorks UML Doclet 来生成 UML。

Its works really well . At least i am happy . See the way to use it NetBeans 7.0 and 7.1 UML plugin

它的工作非常好。至少我很开心。查看使用方法NetBeans 7.0 and 7.1 UML plugin

Hope this helps!

希望这可以帮助!