How to represent “event” in a UML Class Diagram?

后端 未结 2 1304
-上瘾入骨i
-上瘾入骨i 2021-02-20 12:49

This is my code snippet

public class Notation : INotifyPropertyChanged
{
    public event PropertyChangedEventHandler PropertyChanged;

    private Notes _note;
         


        
相关标签:
2条回答
  • 2021-02-20 13:18

    You can define receptions in class definition. Reception is type of behavioral feature. If you define it, instance of class can accept signal events from environment. Other way to define events in UML is using behavioral diagrams. Activity diagram has event element to accept events of specific types during execution. State Machine diagram has transitions with trigger definition, which represents event acceptance as well. Interaction diagram represents events as receiving or sending messages. Behavior definitions (represented by behavioral diagrams) can be assigned to class definition as classifier behavior or owned behaviors. Owned behavior definition defines ability of owning class to react on event occurrences.

    Your example just defines attribute of class, but not ability to accept event by class instance.

    0 讨论(0)
  • 2021-02-20 13:30

    Here is the UML stereotype in the game. Just stereotype this property:

    enter image description here

    Note that _note is a plain, private property.

    0 讨论(0)
提交回复
热议问题