简体   繁体   English

如何在 UML 类图中表示类的添加?

[英]How can I represent addition of classes in UML class diagram?

I am required to use a UML class diagram to represent a model implementation done in Python.我需要使用 UML 类图来表示在 Python 中完成的模型实现。 I have a case where Kernel_A + Kernel_BKernel_AB using __add__() method in the class.我有一个案例, Kernel_A + Kernel_BKernel_AB在类中使用__add__()方法。

These are class variables of a model, called Model_A , which is itself also a class variable of a class which performs estimation, lets call this Algorithm_A .这些是模型的类变量,称为Model_A ,它本身也是执行估计的类的类变量,我们称之为Algorithm_A Algorithm_A also has a class variable which is a separate model, Model_B , which is not related to the kernels. Algorithm_A也有一个类变量,它是一个单独的模型Model_B ,它与内核无关。

Primarily, I am not clear on how to represent the relation between the kernel classes in the UML class diagram.首先,我不清楚如何在 UML 类图中表示内核类之间的关系。 Meaning that the kernel_AB is an addition of the classes kernel_A and kernel_B .这意味着kernel_AB是类kernel_Akernel_B Both of kernel_A and kernel_B have the same methods, but different class variables given that they are dictated by different parameters. kernel_Akernel_B具有相同的方法,但由于它们由不同的参数指定,因此具有不同的类变量。

I am also not entirely clear on how to represent the class variable relationship between Model_A and Algorithm_A .我也不完全清楚如何表示Model_AAlgorithm_A之间的类变量关系。 Is this an aggregation relationship, shown with a diamond arrow?这是一个聚合关系,用菱形箭头表示吗?

To reiterate the components and relations:重申组件和关系:

  • Kernel_A + Kernel_BKernel_AB ( __add__ method to create Kernel_AB ) Kernel_A + Kernel_BKernel_AB (创建Kernel_AB __add__方法)

  • Kernel_ABModel_A ( Kernel_AB class variable of Model_A ) Kernel_ABModel_AKernel_AB的类变量Model_A

  • Model_AAlgorithm_A ( Model_A class variable of Algorithm_A ) Model_AAlgorithm_AModel_A的类变量Algorithm_A

  • Model_BAlgorithm_A ( Model_B class variable of Algorithm_A Model_BAlgorithm_AModel_B的类变量Algorithm_A

Your question is not fully clear about the Kernel... stuff.你的问题并不完全清楚Kernel...东西。 Nevertheless here an answer to your question about the relations between algorithms and models:不过,这里是您关于算法和模型之间关系的问题的答案:

在此处输入图片说明

I assumed that Model_X were unrelated classes.我假设Model_X是不相关的类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM