gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-03 03:49:57 24 4
gpt4 key购买 nike

如果我对信号的理解是正确的,那么这是两个或多个对象之间的异步消息。例如在 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com