且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 UML 图中对 python 属性进行建模

更新时间:2023-01-12 12:29:49

我建议您阅读 UML ***实践:属性或关联,由另一个名为 的 Stack Overflow 用户提供海尔特·贝勒肯斯.它简单地说:

I recommend you read UML Best Practice: Attribute or Association, by another Stack Overflow user named Geert Bellekens. It states simply:

为数据类型使用类和属性的关联.

Use Associations for Classes and Attributes for DataTypes.

您应该在连接到这些 UML 类的 UML 关联的末尾编写由非数据类型(具有标识)类型化的 Python 属性.您应该在 UML 类的属性框中编写由简单数据类型(除了它们的值之外没有其他身份)键入的 Python 属性.

You should write the Python attributes that are typed by non-datatypes (which have identity) at the ends of UML associations connecting to those UML classes. You should write the Python attributes typed by simple datatypes (which have no identity other than their value) in the UML class' attribute box.

访问器和修改器在很大程度上只是噪音.模型编译器或 IDE 可以为您生成这些.

The accessors and mutators are largely just noise. A model compiler or IDE can generate those for you.