是否可以从 Enterprise Architect 中的用例、Activity 或序列图生成代码?
Is it possible to generate code from Use Case, Activity or Sequence Diagram in Enterprise Architect?
我是软件工程专业的学生。我的 "Software Architecture and Design" 讲师告诉我们,我们可以从所有(或大多数)UML 图生成源代码。
我已经可以/已经从 class 图中生成代码。我无法从其他图表生成代码。
我是否必须以某种方式将这些图与 class 图连接起来才能做到这一点?
这简直就是胡说八道。您根本无法从任何图表生成代码。但是,您可以从 UML 模型生成代码。这可以(但不是必须)有几个图表来帮助人类可视化。
现在,代码与 类 相关。这意味着您至少需要在模型中定义一些 类。用例有助于理解为什么 类 会做他们应该做的事情。但是在任何情况下都不能从用例创建代码。
还有其他模型元素可帮助支持创建更详细的代码。那些是例如可以转换为等效代码段的状态机。
Activity 和序列图还有助于可视化某些代码段在执行期间如何 运行。但是您不会(认真地)使用它们来创建代码。
我想我找到了答案。我们可以生成代码。假设我有一个 "use case"。我右键单击它。转到 "advance" 和 select "instance classifier"。在那里,我实际上可以让我的 "use cases" 、 "sequence diagram objects" 等成为已经创建的 class 的实例,或者我什至可以在那里创建一个 class 。
是的,你可以,但它并不像你描述的那么简单。 Model-Driven Architecture 目前是一个活跃的研究领域,但还没有真正 "caught on"。它的支持者认为它允许更高级别的抽象,就像 C 提供比汇编语言更高级别的抽象以及 Java 提供比 C 更高级别的抽象一样。我认为这 如果他们能得到正确的工具, 将来可能会非常有用。
实际上,这甚至不是一个全新的想法 - 一般图形编程的想法(如果你仔细想想,它基本上是 UML 派生编程的概括)至少从我所知道的 1980 年代(可能更早)。事实上,Frederick Brooks Jr. 在 No Silver Bullet – Essence and Accident in Software Engineering(最初于 1986 年出版并出现在当前版本的 The人月神话):
A favorite subject for Ph.D. dissertations in software engineering is graphical, or visual, programming, the application of computer graphics to software design. Sometimes the promise of such an approach is postulated from the analogy with VLSI chip design, where computer graphics plays so fruitful a role. Sometimes this approach is justfied by considering flowcharts as the ideal program design medium, and providing powerful facilities for constructing them.
Nothing even convincing, much less exciting, has yet emerged from such efforts. I am persuaded that nothing will...
他的论点是,在编写它时,工具还没有 "there";例如,屏幕尺寸非常小。此外,流程图实际上是一种非常糟糕的设计机制。另外,
More fundamentally, as I have argued above, software is very difficult to visualize. Whether we diagram control flow, variable scope nesting, variable cross-references, data flow, hierarchical data structures, or whatever, we feel only one dimension of the intricately interlocked software elephant. If we superimpose all the diagrams generated by the many relevant views, it is difficult to extract any global overview. The VLSI analogy is fundamentally misleading - a chip design is a layered two-dimensional object whose geometry reflects its essence. A software system is not.
我会留给你判断你是否同意他的观点或者这是否仍然适用。
所以,总结一下:是的,这至少在理论上是可行的,并且已经付出了相当大的努力从 UML 图生成代码,但是您需要多个图来生成比基本 class 结构更多的东西和方法存根。不是写个用例图,按个按钮,就神奇的拥有一个完整的软件系统。
我是软件工程专业的学生。我的 "Software Architecture and Design" 讲师告诉我们,我们可以从所有(或大多数)UML 图生成源代码。 我已经可以/已经从 class 图中生成代码。我无法从其他图表生成代码。 我是否必须以某种方式将这些图与 class 图连接起来才能做到这一点?
这简直就是胡说八道。您根本无法从任何图表生成代码。但是,您可以从 UML 模型生成代码。这可以(但不是必须)有几个图表来帮助人类可视化。
现在,代码与 类 相关。这意味着您至少需要在模型中定义一些 类。用例有助于理解为什么 类 会做他们应该做的事情。但是在任何情况下都不能从用例创建代码。
还有其他模型元素可帮助支持创建更详细的代码。那些是例如可以转换为等效代码段的状态机。
Activity 和序列图还有助于可视化某些代码段在执行期间如何 运行。但是您不会(认真地)使用它们来创建代码。
我想我找到了答案。我们可以生成代码。假设我有一个 "use case"。我右键单击它。转到 "advance" 和 select "instance classifier"。在那里,我实际上可以让我的 "use cases" 、 "sequence diagram objects" 等成为已经创建的 class 的实例,或者我什至可以在那里创建一个 class 。
是的,你可以,但它并不像你描述的那么简单。 Model-Driven Architecture 目前是一个活跃的研究领域,但还没有真正 "caught on"。它的支持者认为它允许更高级别的抽象,就像 C 提供比汇编语言更高级别的抽象以及 Java 提供比 C 更高级别的抽象一样。我认为这 如果他们能得到正确的工具, 将来可能会非常有用。
实际上,这甚至不是一个全新的想法 - 一般图形编程的想法(如果你仔细想想,它基本上是 UML 派生编程的概括)至少从我所知道的 1980 年代(可能更早)。事实上,Frederick Brooks Jr. 在 No Silver Bullet – Essence and Accident in Software Engineering(最初于 1986 年出版并出现在当前版本的 The人月神话):
A favorite subject for Ph.D. dissertations in software engineering is graphical, or visual, programming, the application of computer graphics to software design. Sometimes the promise of such an approach is postulated from the analogy with VLSI chip design, where computer graphics plays so fruitful a role. Sometimes this approach is justfied by considering flowcharts as the ideal program design medium, and providing powerful facilities for constructing them.
Nothing even convincing, much less exciting, has yet emerged from such efforts. I am persuaded that nothing will...
他的论点是,在编写它时,工具还没有 "there";例如,屏幕尺寸非常小。此外,流程图实际上是一种非常糟糕的设计机制。另外,
More fundamentally, as I have argued above, software is very difficult to visualize. Whether we diagram control flow, variable scope nesting, variable cross-references, data flow, hierarchical data structures, or whatever, we feel only one dimension of the intricately interlocked software elephant. If we superimpose all the diagrams generated by the many relevant views, it is difficult to extract any global overview. The VLSI analogy is fundamentally misleading - a chip design is a layered two-dimensional object whose geometry reflects its essence. A software system is not.
我会留给你判断你是否同意他的观点或者这是否仍然适用。
所以,总结一下:是的,这至少在理论上是可行的,并且已经付出了相当大的努力从 UML 图生成代码,但是您需要多个图来生成比基本 class 结构更多的东西和方法存根。不是写个用例图,按个按钮,就神奇的拥有一个完整的软件系统。