只列出在类的构造函数中定义的属性?

only list attributes defined in the constructor of the class?

我在想,在创建 class 并指定其属性的 UML class 图中,您只定义了 class 的所有属性,其中 can/shall 可在 class 的构造方法中找到。 当我尝试使用视觉范式对我的 (python-) 代码进行逆向工程时,每个属性都显示在生成的 classes 中(那些在构造函数中声明的和那些在 class 的其他方法中声明的)。

我想,这是视觉范式的错误。

有人可以告诉我,如果我的假设错了,或者 VP 代码生成器是否错了。提前致谢。

TL;DR Visual Paradigm 的逆向工程自动机在这方面似乎还不错。


Sparx Systems → UML 2 Tutorial → Class Diagram

Class Diagrams

The class diagram shows the building blocks of any object-orientated system. Class diagrams depict a static view of the model, or part of the model, describing what attributes and behavior it has rather than detailing the methods for achieving operations. Class diagrams are most useful in illustrating relationships between classes and interfaces. Generalizations, aggregations, and associations are all valuable in reflecting inheritance, composition or usage, and connections respectively...

Python 代码在 运行 时动态创建的属性的上下文中,我的翻译是 class 将永远 use/have 的所有属性(无论何时它们恰好出现在 运行 时间)应该在属性隔间中。

UML Class Diagram 应该表示静态不可变(“编译时”)视图的最大可能的内存结构(由称为 classes 的块组成)并属于 UML Structure Diagrams 类别。

如果您想要记录(UML-方式)一些属性在运行时间 然后 你需要使用一些属于 UML Behavior Diagrams 类别的图表。

UML class 模型可以以非常动态和多态的方式转换为某些语言(例如 JavaScript)的计算机可执行模型。这只是一个实现问题,UML 并不太关心。 UML关心的主要是Platform-independent model (PIM).