简体   繁体   English

动作3:事件处理顺序图

[英]Actionscript 3: Sequence Diagrams for Event Handling

i have to draw some sequence diagrams for a software i wrote. 我必须为我编写的软件绘制一些时序图。 In my Software i have some Objects that dispatch custom Events and other Objects that listens for these events. 在我的软件中,我有一些对象可以调度自定义事件,而其他对象则可以监听这些事件。

When it comes to illustrate Eventlisteners und dispatchEvent-function i'm a little bit confused how to do that. 当要说明Eventlisteners和dispatchEvent-function时,我有点困惑该怎么做。 I googled a lot, but couldn't find the right hint :( 我在Google上搜索了很多,但是找不到正确的提示:(

Or is a sequence diagram not a good choice for explaining event handling? 还是时序图不是解释事件处理的好选择?

Thanks for your help! 谢谢你的帮助!

There is no definitive answer to your question, because creating useful diagrams largely depends on what kind of information you want to convey to the reader. 您的问题没有明确的答案,因为创建有用的图表很大程度上取决于您想传达给读者的信息类型。 My advice is: You will never be able to show all your program's functionality in just one diagram; 我的建议是:您将永远无法仅用一张图来显示程序的所有功能; event handling is often too complex and ugly - try to split it up into smaller parts and decide individually, which kind of diagram is useful for which aspects you want to show. 事件处理通常过于复杂和丑陋-尝试将其拆分成较小的部分并分别决定,哪种类型的图表对于要显示的方面很有用。

For each one, your focus should always be on the reader: What do you want him or her to understand? 对于每一个人,您应该始终将重点放在读者身上:您希望他或她理解什么?

To start with, it's usually best to write user stories and show use cases, if you don't have those already. 首先,通常最好编写用户案例并显示用例,如果还没有的话。 They convey the functionality your program was made for, and help you to identify processes and organize the way in which you think about your program. 它们传达了您的程序所针对的功能,并帮助您识别流程并组织您对程序的思考方式。 For each of those processes, a sequence diagram is probably most useful to show how things work. 对于这些过程中的每一个,序列图可能对于显示事物如何工作最有用。 For example, if one of your program features is uploading an image, you should draw a sequence diagram showing the main components, objects and sequences of events involved only in the upload procedure. 例如,如果您的程序功能之一是上载图像,则应绘制序列图,显示仅涉及上载过程的主要组件,对象和事件序列。

The next step is to categorize the remaining events and objects, which are more fine-grained or do not interact directly with the user: Which events are internal (ie dispatched and handled within the same object), which are external (between some objects), or even global (affecting the entire application). 下一步是对其余事件和对象进行分类,这些事件和对象的粒度更细或不会直接与用户交互:哪些事件是内部的(即,在同一对象内调度和处理),哪些是外部的(在某些对象之间) ,甚至全局(影响整个应用程序)。 This will help you to identify groups of objects interacting with one another. 这将帮助您识别彼此交互的对象组。
Depending on how complex an object is, I often display internal event sequences within a state diagram or flow chart. 根据对象的复杂程度,我经常在状态图或流程图中显示内部事件序列。

If you have some smaller object groups where the interactions are not too complex and more interesting in terms of who does what why instead of when , you can possibly use slightly altered class diagrams - these might not be very formal, but for some concepts, they are often more useful than flow charts, state or sequence diagrams. 如果你有其中的互动是不是太复杂,谁而言更有趣一些规模较小的对象组做了什么为什么时候 ,你都不可能使用稍微改变类图来代替-这也许不是很正规,但对一些概念,它们通常比流程图,状态图或顺序图有用。

It should also be mentioned, that in some cases, a diagram doesn't really help at all. 还应该提到的是,在某些情况下,图表根本没有帮助。 Sometimes it is far more useful to write a short text providing an example, or collect information in tables. 有时写一个简短的文本以提供示例,或在表中收集信息会更加有用。 Documentation is complete, when a reader understands the concepts of what your program does and how it does so. 当读者了解程序的功能以及如何执行的概念时 ,说明文件即告完成。 For everything else, there is always the source code. 对于其他所有内容,总会有源代码。

I don't know exactly what you are trying to do here but sequence diagrams are perfectly capable of representing the sort of system you have described. 我不完全知道您要在这里做什么,但是顺序图完全可以代表您所描述的系统。 Here is an article on sequence diagrams. 是有关时序图的文章。 Look at the section on asynchronous messages and concurrency. 查看有关异步消息和并发的部分。 Another article actually has an example of an event listener. 一篇文章实际上有一个事件侦听器的示例。 It talks about both sequence and class diagrams. 它讨论了序列图和类图。 I guess the example of sequence diagrams will be of interest to you. 我想序列图的示例将使您感兴趣。

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

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