java - UML:信号分类器与类分类器

标签 java uml

如果我对信号的理解是正确的,那么这是两个或多个对象之间的异步消息。例如在 UML 中我们有一个信号分类器:

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

然后我们可以用Java写这个信号如下:

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

但是,在 Java 中我们有一个 CLASS,但是在 UML 中我们有一个 SIGNAL 分类器,而不是一个 CLASS 分类器(更新:我的意思是在这个例子中)。怎么解释呢?

最佳答案

您对 UML 信号的讨论是正确的。

来自规范:

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 确实有一个来自规范的 CLASS 分类器。 (强调我的):

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 独立于编程语言。

    在 Java 中,UML 类和信号分类器是作为类实现的。

    又如:UML有接口(interface)分类器,而C++没有 接口(interface)。 C++ 中的接口(interface)是一个抽象(纯虚拟)类。

关于java - UML:信号分类器与类分类器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34197071/

相关文章:

Java并行矩阵乘法

java - Spring MVC : correct exception handling

java - 为什么某些 Unicode 字符在控制台中显示为问号?

java - 在创建 bean 时调试

Java 语法等同于 Python 语法?

uml - 关联和依赖之间的区别?

uml - 用例图应该说明什么级别的复杂性?

UML - 如何建模一个/或/两个(联合)概念?

UML 关联和依赖

oop - UML 箭头的解释