在 Visual Studio 2017 中的类图中创建聚合和组合 [英] Creating Aggregation and Composition in class diagram in Visual Studio 2017

查看:40
本文介绍了在 Visual Studio 2017 中的类图中创建聚合和组合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑在 Visual Studio 中创建类图.我注意到工具箱似乎只允许类之间的关联关系.

I am thinking about creating a class diagram in Visual Studio. I notice that the Toolbox only appears to allow Association relationships between classes.

是否可以在类图中创建更强的关系,即聚合和组合关系?

Is it possible to create stronger relationships in the class diagram, i.e. Aggregation and Composition relationships?

另外,是否可以从代码中自动创建类图?

Also, is it possible to automatically create the class diagram from the code?

推荐答案

好问题.

首先:Visual Studio (VS) 类设计器不是 CASE 工具(例如 Enterprise Architect 等).
它只是源代码的类表示.这意味着类设计器中的类始终与源代码中的类同步.如果删除源代码中的某些属性或方法,它会与类设计器同步,反之亦然.

First of all: Visual Studio (VS) Class Designer is not a CASE Tools (like Enterprise Architect and etc.).
It is only a class representation of the source codes. Meaning that classes in class designer are always synchronized with the classes in the source code. If you delete some attributes or methods in source code, it synchronized with class designer and vise versa.

第二:这个问题的答案隐藏在将关联和聚合(和组合)映射到源代码中.

Secondly: The answer of this question hides in mapping Association and Aggregation (and Composition) to source code.

要将关联、聚合和组合映射到源代码,请参见:参考文献 1参考文献 2.

To map Associations, Aggregation and Composition to source code see: Reference 1 and Reference 2.

在某些情况下,无法从源代码检测类之间的关联或聚合或组合关系.

例如,下面代码中CustomerCar之间是什么类型的关系?

For example, what type of relationship is between Customer and Car in below code?

public class Customer {
    private String name;
    private String address;
    private String contactNumber;

    private Car car;        
}


public class Car {
    private String modelNumber;
    private Customer owner;
}

它可以是关联或聚合.

最后,由于上述第一个和第二个原因,Visual Studio 类图没有聚合和组合.

Finally, because of first and second reasons as described above, Visual Studio Class Diagram do not have Aggregation and Composition.

这篇关于在 Visual Studio 2017 中的类图中创建聚合和组合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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