UML:我该怎么做……? [英] UML: How do I do this...?

查看:41
本文介绍了UML:我该怎么做……?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于UML的几个问题:我是否在 UML 图中包含主类?如果我确实包含它,并且它实例化了对象,我是否会从我的主类到它实例化的类绘制一个空箭头(例如 ->)?什么时候使用菱形和箭头?

Several questions about UML: Do I include the main class in my UML diagram? If I do include it, and it instantiates objects, do I draw an empty arrow (such as ->) from my main class to the classes it instantiates? When do I use the diamond vs. the arrow?

我只是对这三件事很好奇...虽然一篇文章也很有帮助,但有人可以解决这三个问题吗?

I'm just curious about those 3 things... While an article would also be very helpful, could someone address those three questions?

非常感谢.

推荐答案

我是否在 UML 图中包含主类?

UML 图有很多种,但我怀疑这里指的是类图.你的问题的答案就是:如果你愿意.UML 的美妙之处在于您可以制作许多细节不同的图表.有些图表将只显示几个类,有些则显示很多.这个想法是你在不同的视图中为不同的受众绘制系统的不同部分.根据您的喜好绘制或多或少的图表.如果您正在制作一个只有几个类的非常小的应用程序,那么显示主类可能是有意义的.给它一个构造型或使用将其标识为主应用程序类"的注释.

There are many types of UML diagrams, but I suspect here you mean a class diagram. The answer to your question is literally: if you want to. The beauty of UML is that you can make many diagrams, that vary in detail. Some diagrams will show just a few classes, some many. The idea is that you diagram different parts of the system, at different views, for different audiences. Diagram as much or as little as you like. If you are making a very small application with just a few classes, then it probably will make sense to show the main class. Give it a stereotype or use a comment that identifies it as a "main application class."

如果我确实包含了它,并且它实例化了对象,我是否会从我的主类到它实例化的类绘制一个空箭头(例如 ->)?

你当然可以,再次如果你愿意",在某种程度上会有一个依赖:主类依赖"其他类,因为它以某种方式使用它们.也就是说,如果主类 A 实例化了类 B 的对象,则类 A 需要类 B 进行编译,因此您可以根据需要将其显示为依赖项.

You certainly may, again "if you want to," There will be a dependency here in a way: the main class "depends on" the other classes because it uses them somehow. That is, if main class A instantiates objects of class B, then class A needs class B to compile, so you may show this as a dependency if you wish.

我什么时候使用菱形和箭头?

菱形表示聚合组合,用法如下:如果 A 类有 B 类字段,则从 A 到 B 的箭头上有一个菱形要求 A 方.普通箭头"只是显示了一个相对不明确的依赖关系.当 A 类使用时,您可以从 A 类到 B 类使用它,不知何故是 B 类.也许 A 类的方法使用 B 类的实例作为局部变量.A 中 B 的包含(组合或聚合)并不隐含在普通依赖项中.

The diamond shows aggregation or composition and is used as follows: if class A has a field of class B, then an arrow from A to B with a diamond on the A side is called for. The "plain arrow" just shows a relatively unspecificed dependency. You can use it from class A to class B when class A uses, somehow class B. Perhaps a method of class A uses an instance of class B as a local variable. No containment (composition or aggregation) of a B in an A is implied with the plain dependency.

这篇关于UML:我该怎么做……?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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