Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UML: signal classifier vs class classifier

Tags:

java

uml

If I understand signal right this is an asynchronous message between two or more objects. For example in UML we have a signal classifier:

-----------------
|  << signal >> |
|  SomeEvent    |
-----------------
|id:Int         |
|text:String    |
-----------------
|getId()        |
|getText()      |
-----------------

Then we can write this signal in Java as following:

class SomeEvent{
  private final int id;
  private final String text;
  //+constructor + getters
}

However, in Java we have a CLASS, but in UML we have a SIGNAL classifier, but not a CLASS classifier(Update: I mean in this example). How to explain it?

like image 260
Pavel_K Avatar asked Dec 10 '15 08:12

Pavel_K


2 Answers

Your discussion about UML signals is correct.

From the spec.:

10.3.3.1 Signals

A Signal is a specification of a kind of communication between objects in which a reaction is asynchronously triggered in the receiver without a reply. The receiving object handles Signals as specified by clause 13.3. The data carried by the communication are represented as attributes of the Signal. A Signal is defined independently of the Classifiers handling it.


However, in Java we have a CLASS, but in UML we have a SIGNAL classifier, but not a CLASS classifier. How to explain it?

  1. UML does have a CLASS classifier, from the spec. (emphasis mine):

11.4 Classes

... The purpose of a Class is to specify a classification of objects and to specify the Features that characterize the structure and behavior of those objects.

11.4.4 Notation

A Class is shown using the Classifier symbol. As Class is the most widely used Classifier, no keyword is needed to indicate that the metaclass is Class.

  1. UML is programming-language-independent.

    In Java, UML class and signal classifiers are implemented as classes.

    Another example: UML has a interface classifier, but C++ does not have interfaces. An interface in C++ would be an abstract (pure virtual) class.

like image 197
sergej Avatar answered Nov 14 '22 22:11

sergej


In fact UML is richer than Java. In UML, Signal, Class, Component, and Collaboration classifier concepts would correspond to Java Class.

like image 21
Red Beard Avatar answered Nov 14 '22 22:11

Red Beard