UML:信号 classifier 与 class classifier
UML: signal classifier vs class classifier
如果我对信号的理解是正确的,那么这是两个或多个对象之间的异步消息。例如在 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比Java更丰富。
在 UML 中,信号、Class、组件和协作分类器概念将对应于 Java 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?
- UML 确实有一个 CLASS classifier,来自规范。 (强调我的):
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.
UML 是独立于编程语言的。
在 Java 中,UML class 和信号 classifiers 被实现为 classes.
另一个例子:UML有接口classifier,但是C++没有
接口。 C++ 中的接口将是抽象的(纯虚拟的)class.
如果我对信号的理解是正确的,那么这是两个或多个对象之间的异步消息。例如在 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比Java更丰富。 在 UML 中,信号、Class、组件和协作分类器概念将对应于 Java 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?
- UML 确实有一个 CLASS classifier,来自规范。 (强调我的):
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.
UML 是独立于编程语言的。
在 Java 中,UML class 和信号 classifiers 被实现为 classes.
另一个例子:UML有接口classifier,但是C++没有 接口。 C++ 中的接口将是抽象的(纯虚拟的)class.