英文:
Is there a way to generate Java code from UML Activity diagrams in Netbeans?
问题
有没有办法反过来做,比如将现有的活动图转换成Java代码?
英文:
I have seen previous questions on how to generate UML diagrams from code. Is there a way to do it in reverse, like having an existing activity diagram to convert into Java code?
答案1
得分: 1
这是可能的。ADs有相当有限的语言构造。Decision
将会被翻译为简单的if
结构。CallBehavior
只是对类操作的调用。而Fork
/Join
需要一些支持才能映射到系统线程操作的调用。
但这还不是全部。我不知道有任何系统是完全使用ADs来描述的。通常只有少数几个ADs,而许多(或者说大多数)用例只是以文本形式描述。
还有可执行的UML,你可以研究一下这个。在任何项目中,我都没有看到它在现实中的应用。对我来说,UML用于(抽象)建模。你不需要过多关注实现细节。然后你将工作交给编码/开发人员。他们生活在一个略有不同的世界。当你在UML中已经完成了所有的编程工作时,你不会让他们感到满意。而且肯定不会让他们接受在UML中进行编程。
英文:
This would be possible. ADs have quite a limited number of language constructs. Decision
would translate to a simple if
construct. CallBehavior
would just be invocation of a class operation. And Fork
/Join
would need some support to be mapped to invocation of system threading operations.
But that's not all of it. I don't know of any system that's described in full with ADs. There are usually only a few ADs and many (/most) use cases are just described in text.
There's executable UML which might be something you can look into. I haven't seen it in reality in any project. To me UML is for (abstract) modeling. You don't bother too much with implementation. Then you pass on to the coder/hacker troop. They live in a somewhat different world. And you won't make them happy when doing all the programming already in UML. And for sure you won't get them into programming in UML.
答案2
得分: -2
无法从UML生成可工作的代码。您只能生成具有空方法的对象。
例如,Enterprise Architect可以执行此操作。它还可以对现有类进行反向工程化。但是,这两个功能(在我看来)并不像听起来那么有用。最终,这只会使程序员的工作变得比以前更加复杂。这些图表甚至无法替代手动创建的文档。
英文:
It is impossible to generate working code from UML. You can only generate objects with empty methods.
Enterprise Architect can do that, for example. It can also reverse engineer existing classes. But both features are (in my opinion) much less useful as it sounds. At the end, you make the work of the programmer more complicated as before. These diagram can even not replace manually created documentation.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论