应该先画类图还是序列图?

发布于 2024-10-11 10:00:52 字数 149 浏览 6 评论 0原文

我和我的大学教授就 UML 图进行了讨论。 他认为应该在绘制类图之前先绘制序列图,但我认为恰恰相反。我认为完成用例图后,下一个图应该是类图,之后我们应该看到序列图。 Rational Rose要求我们使用序列图中的类,这些类已经在类图中。

谁能帮我解决这个问题吗?

I've had this discussion with my professor at college about UML diagrams .
He believes that sequence diagrams should be drawn before getting to class diagrams, but I think the opposite . I think after finishing the usecase diagram , the next diagram should be class diagram and after that we should get to sequence diagram.
Rational rose requires us to use the classes in sequence diagram, which are already in class diagram.

Can anyone help me with this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

寒尘 2024-10-18 10:00:53

我认为你们都错了。它们应该同时绘制。当您绘制序列图时,您无疑会想出跟踪状态所需的属性,或者在真空中绘制类图时您没有想到的属性。

当然,这是高度主观和个人的,但多年的现实经验(而不是学术理论)教会了我同时致力于这两方面。也许从类图开始,但是当您开始查看流程时,类图总是会发生变化。

I think you're both wrong. They should be drawn at the same time. As you're drawing your sequence diagram, you will undoubtedly come up with properties that you will need to keep track of the state, or that you hadn't thought of if you do the class diagram in a vacuum.

Of course, this is highly subjective and personal, but years of real-world experience (as opposed to academic theory) have taught me to work on both at the same time. MAYBE starting with the class diagram, but the class diagram invariably changes when you start going through process flows.

羁绊已千年 2024-10-18 10:00:53

嗯,这在很大程度上取决于你计划如何做事。我认为这是一个主观问题。如果您更愿意解释为您的用例执行的操作,并且在完成之后根据执行序列所需的内容编写类,那么您的教授是对的。

但是,如果您更愿意确定类的结构,然后据此调整操作序列,那么您将首先绘制类图,然后再绘制序列。

根据我的经验,我同时做这些事情。我将基本属性添加到类图中,但没有添加操作,在绘制序列图时,我将所需的方法和属性添加到类图中。

Well it depends a lot on how you plan to do things. I think it's a subjective matter. If you rather explain the actions performed for your usecases and after this has been done write the classes based on what you need to perform the sequences your professor is right.

But if you prefer to determine what the structure of your classes are and then adapt the action sequence to this then you would do the class diagram first and later the sequence.

In my experience I do them concurrently. I put the fundamental attributes to the class diagram but not the actions, and while I do the sequence diagram I add the methods and attributes that I need to the class diagram.

枫林﹌晚霞¤ 2024-10-18 10:00:53

没有一个标准答案。有多种观点、途径和方法。在统一流程中,我相信您首先确定用例,然后对其进行实现,例如序列图。与用例一样,参与者和系统和/或其部分按顺序交互。实际上,这种交互应该可以帮助您分解设计并进入课堂。一旦有了分析级别的类,您就可以进一步设计类和设计交互。然而,在图表中绘制的内容相当多,大多数时候代码是这个级别上最好的文档,即使生成的图表也太大并且比代码本身更难以理解。

There is no one standard answer. There are several opinions, approaches and methods. In Unified Process I believe you first identify use case and then make realizations for them, e.g. sequence diagrams. As in use cases, there are actors and the systems and/or its parts interacting ina sequence. Actually this interactions should help you decompose your design and get to classes. Once you have classes on the analysis level, you can go further to design classess and design interactions. However these are quite a lot to draw in a diagram, most of the times code is the best documentation on this level, even generated diagrams are too large and more difficult to understand then code itself.

病毒体 2024-10-18 10:00:53

要准备序列图,您需要类而不是类图
您可以在准备序列图的过程中动态准备空类......
识别类对象是准备序列的一部分,或者您可以尝试预先识别您的对象......
序列是逻辑过程,类图是最终输出

To prepare sequence diagram you need classes not the class diagram
You can prepare empty classes on the fly while in process of preparing sequence diagram....
Identification class objects in be part of preparing sequence or you can try to identify your objects before hand....
sequence is logical process while class diagram is end output

原谅我要高飞 2024-10-18 10:00:53

我认为创建图没有顺序,因为两者都是系统的两种不同视图:类图结构(静态)和序列是行为(动态)。我将从序列图开始,因为当您浏览序列时,您会发现更多要创建的类。做当时对你有意义的事情。如果您进行更多面向对象的编程,我会考虑在序列之前执行类。

I don't think there is an order for creating diagrams since both are two different views of a system: class diagram structural (static) and sequence is behavioral (dynamic). I would start with sequence diagrams since you will discover more classes to create as you go through sequences. Do whatever makes sense for you at the time. If your doing more object oriented programming, I would consider doing classes before sequences.

青衫负雪 2024-10-18 10:00:53

除了最简单的系统之外,所有系统的结构和行为模型都是自然地同时和迭代地创建的,并随着时间的推移而不断完善。

您可能有一些“对象发现”方法,例如 CRC 卡,它将产生一组初始类,具有协作(与它们交互的类)和职责,这会通知它们需要的方法以及内部行为/状态/活动。

然后,您可能希望使用序列图或通信图来探索用例和场景,这将公开所需对象通信的详细信息,从而通知生成公共方法和关系以细化类图,同时探索系统行为这可能会产生更多要创建的对象和类。

您可能还想探索类的内部行为,特别是当它们具有有状态和/或主动行为时;活动和状态机图对此很有用。

不管怎样,我怀疑 Rational Rose 的使用确实是图表创建顺序的决定因素。 Rational 可能要求序列图上的类存在,但我想它们实际上不需要出现在类图上;它们可能同样可以在序列图上创建,然后放置在类图上,甚至可以在项目资源管理器或该工具中的任何等效项中创建。即使创建类的唯一方法是将其放置在类图上,也不需要您在探索序列图上的交互之前细化和完成类或其关系。

Structural and behavioural models for all but the very simplest systems are naturally created simultaneously and iteratively, refining both over time.

You may have some method of "object discovery" such as CRC cards, which will yield a set of initial classes, with collaborations (the classes they interact with) and responsibilities, which informs both the methods they will need, and internal behaviour/state/activity.

You may then want to explore the use cases and scenarios using sequence or communication diagrams, this will expose the details of the required object communication and therefore inform the generation of public methods and relationships to refine the class diagram while at the same exploring the system behaviour which may yield further objects and classes to be created.

You may also want to explore the internal behaviour of classes, especially if they have stateful and/or active behaviour; activity ans state-machine diagrams are useful for this.

Either way I doubt that the use of Rational Rose is really the determinant of diagram creation order. Rational may require the classes on a sequence diagram to exist, but I imagine that they need not actually appear on a class diagram; they can probably equally be created on the sequence diagram and then later placed on a class diagram, or even created in the project explorer or whatever the equivalent is in that tool. Even if the only method of creating a class is to place it on a class diagram, that does not require you to refine and complete the class or its relationships before exploring interactions on a sequence diagram.

我不咬妳我踢妳 2024-10-18 10:00:53

你需要买一些衣服,你将如何进行。你先开始选择衣服还是先决定去哪里?同时,如果你想买衬衫,你会去鞋店吗?

因此两者都是迭代的,但第一步肯定是在非常高(组件)级别上进行序列,然后深入到类级别序列

You need to buy some clothes, how you will proceed. You start choosing clothes first or you will decide first where to go? At the same time, will you go to shoe store if you want to buy shirt.

So both are iterative, but definitely first step is sequence on very high (component) level then drill down to class level sequence

很糊涂小朋友 2024-10-18 10:00:53

您应该首先决定您的应用程序流程,这意味着您应该首先绘制序列图。它将显示您的应用程序的流程,之后您应该查看类图。

You should first decide your application flow,means you should first draw a sequence diagram. It will show the flow of your application after this you should go for class diagram.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文