是否有描述性的UML方法来描述线程 [英] Is there an inituitive UML approach to depict threads

查看:241
本文介绍了是否有描述性的UML方法来描述线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很喜欢使用UML图来描述我的软件.在大多数情况下,这些图供我自己使用,并且将它们用于更多涉及的代码段,交互等.在将来,我将受益于这些图.

I'm fond of using UML diagrams to describe my software. In the majority of cases the diagrams are for my own use and I use them for more involved pieces of code, interactions etc. where I'll benefit from being able to look back over them in the future.

我发现自己做了几种不同的事情,就是绘制线程图.就其性质而言,线程往往会出现在涉及更多的代码段中,并且对其进行跟踪通常是我的设计文档的主要目的.

One thing I've found myself doing a few different ways is diagramming threads. Threads by their nature tend to pop up in the more involved pieces of code and keeping track of them is often a primary purpose of my design documents.

过去,我曾在序列图中使用符号来显示新线程的创建,但回头看一些图,有时对象生命周期(序列图用于)与线程生命周期之间有时是模棱两可的.有没有将线程合并到UML中的更好方法?

In the past I've used a symbol in a sequence diagram to show the creation of a new thread but looking back at some diagrams doing that it's sometimes ambiguous between an object's lifetime - which sequence diagrams are for - and a thread's lifetime. Is there a better approach for incorporating threads into UML?

推荐答案

我设法生成了一个对我来说有意义的图表.基本前提是,我将代表类实例的灰色框与代表线程生存期的蓝色框重叠了.它让我跟踪的主要事情是知道在调用某些方法时将在哪个线程上执行.

I managed to produce a diagram that makes sense to me at the time of drawing it. The basic premise is that I've overlaid grey boxes representing class instances with blue boxes representing thread lifetimes. The main thing it lets me keep track of is knowing which thread I will be executing on when I call certain methods.

毫无疑问,有更好,更直观的方法来进行线程和类建模.对我而言,成功的衡量标准是,在六个月的时间里,我自己的图表是否仍能使我获得相同的理解水平.

No doubt there's better and more intuitive ways to do thread and class modeling. The measure of success for me is whether my own diagram still gives me the same level of understanding 6 months down the track.

这篇关于是否有描述性的UML方法来描述线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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