如何在UML类图中最好地表示c#.net事件构造? [英] How can the c# .net event construct best be represented in a UML class diagram?

查看:439
本文介绍了如何在UML类图中最好地表示c#.net事件构造?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在设计一个实体/组件系统,其中实体间通信的问题由事件消息系统来解决。组件被分成两部分,一个在实体中,一种是子系统中的实体代理,通过观察者类型系统保持同步。我试图通过事件和代理实现。



我正在尝试对我的应用程序的事件/消息传递系统的结构进行建模,我对代理人有麻烦。现在的方式是显示系统中委托,eventArgs和实​​体的图(附件),但是它们的关系的性质只是被表示为通用关联。我还有一个第二个图显示了系统的接口。我需要显示在这些对象中引发的事件,因为系统中大部分的复杂性都是这样的。



我知道我需要动态协作和时序图好的,但是我想弄清楚我需要什么样的类型和多少个不同的事件支持类,以及继承结构的外观。我想给自己一个选择的消息类型,我知道将一起工作。那么我可以从这些预定义的类型中选择一个EventArgs派生和一个委托类型,以便在动态图表和组件构建时间重新使用。



确定是否将事件建模为属性或操作。我一直在尝试为代理使用关联类和一个具有事件构造型的OnSomeEvent()类型操作。我不喜欢这个,因为一个事件不是一个操作。我已经在这个On ****()命名约定的代码中保护了方法。代理签名,组播行为和观察者模式并不真正被这种方法所捕获。



其他用于表达这些复杂和紧密耦合的类的方法是什么?对我来说,图表的要点是记录和更全面地了解系统中的界面。在我进程的这个阶段,我希望冻结接口并继续实现组件本身。

解决方案

我不会将信号字符包含在静态类图中,因为信号(这是事件是为什么)是动态行为。我将按照他们的身份参加活动代表(即签名),并将其作为课堂的普通操作。我认为这将符合一个想法,即一个对象能够非常适合地发送一个事件,并指定事件的类型。



哪些信号正在哪里订阅谁应该在动态图中建模。



编辑:



您是否考虑过添加类似<<<事件>> <<信号>> 对你的班级的属性进行分类?


I am designing an entity/component system where the problem of intra-entity communication is addressed by an event message system. components are broken into two parts, one in the entity and a sort of "entity proxy" in a subsystem, kept in sync through an observer type system. I am attempting an implementation with events and delegates.

I am trying to model the structure of my application's event/messaging system and I am having trouble with the delegates. The way it is now is a diagram(attached) showing the delegate, eventArgs, and entities in the system, however the nature of their relationships is only being represented as generic associations. I also have a second diagram showing the system's interfaces. I need to show the events that are raised in these objects, as this where most of the complexity in the system is.

I know I need dynamic collaboration and timing diagrams as well, but I am trying to figure out what kind and how many different event support classes I need as well as what the inheritance structure will look like. I want to give myself a choice of message types that I know will work together. I figure then I can choose an EventArgs derivative and a delegate type from these pre-defined types to reuse at dynamic diagramming and component building time.

The main thing I can't figure out is whether to model the event as an attribute or operation. I have been trying to use an association class for the delegate and an OnSomeEvent() type operation with an event stereotype. I don't like this because an event is not an operation. I have protected methods in the code with this On****() naming convention already. The delegate signature, multicast behavior and the observer pattern are not really captured by this approach.

What method are others using to express these complex and tightly coupled classes? The point of the diagrams for me is to both document and more completely understand the interfaces in the system. At this stage in my process I am hoping to freeze the Interfaces and move on to Implementing the components themselves.

解决方案

I wouldn't include the signaling character in a static class diagram because signaling (it's what events are for) is a dynamic behavior. I would take the event delegates as they are (i.e. with their signatures) and include them as ordinary operations of a class. I think this would match the idea that an object is capable of sending an event quite appropirately and it specifies the kind if the event.

Which signals are going where and who is subscribed to whom should be modeled in a dynamic diagram.

EDIT:

Have you considered adding stereotypes like << event >> or << signal >> to classifying attributes on your class ?

这篇关于如何在UML类图中最好地表示c#.net事件构造?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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