如何在 UML 图中对 python 属性进行建模 [英] How to model python properties in UML diagram

查看:53
本文介绍了如何在 UML 图中对 python 属性进行建模的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 UML 类图中对 Python 属性建模的好做法是什么?属性本身是类对象,它们的 getter 和 setter 是类函数.从外部看,它们看起来像实例属性.那么,您建议如何在我的类图中展示它?谢谢

What is a good practice to model python properties in a UML class diagram? Properties themselves are class objects, their getter and setter are class functions. From Outside the class they look like instance attributes. So, how would you suggest to present that in my class diagram? Thanks

推荐答案

我建议您阅读 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.

这篇关于如何在 UML 图中对 python 属性进行建模的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆