简体   繁体   English

在UML类图中,如何显示类创建另一个类的对象但不存储对象引用?

[英]In a UML Class Diagram, how do I show that a class creates an object of another class but doesn't store the object reference?

I've got a class which creates an instance of another class. 我有一个类创建另一个类的实例。 "ServerThread" configures a socket for an incoming connection, and "ServerLogic" waits for any incoming messages. “ServerThread”为传入连接配置套接字,“ServerLogic”等待任何传入消息。

ServerThread creates an instance of ServerLogic, and invokes the "run" method in ServerLogic. ServerThread创建ServerLogic实例,并在ServerLogic中调用“run”方法。 ServerThread does not store a reference to the ServerLogic object, and because these will be running on the same thread, ServerThread will be on hold until ServerLogic stops listening/the socket is closed. ServerThread不存储对ServerLogic对象的引用,并且因为它们将在同一个线程上运行,所以ServerThread将处于保持状态,直到ServerLogic停止侦听/套接字关闭。

Here is an image of the two classes I'm talking about: 这是我正在谈论的两个类的图像:

在此输入图像描述

How would I represent this kind of relationship in a UML class diagram? 我如何在UML类图中表示这种关系?

Thanks. 谢谢。

I understand that your ServerThread and ServerLogic are structurally independent: no reference between each other is maintained. 我知道您的ServerThreadServerLogic在结构上是独立的:不保持彼此之间的引用。 So there is no association between them. 所以他们之间没有联系。 You could however draw a dependency (dashed line with arrow) from ServerThread to ServerLogic with the stereotype «Instantiate» . 但是,您可以使用ServerThread«Instantiate»ServerThreadServerLogic绘制依赖关系(带箭头的虚线)。

在此输入图像描述

Represent it as a 1 to 1 relationship where ServerLogic is a dependent class of ServerThread. 将其表示为1对1关系,其中ServerLogic是ServerThread的依赖类。

Here is general info on UML if you need that: http://www.cs.bsu.edu/homepages/pvg/misc/uml/ 以下是有关UML的一般信息,如果您需要: http//www.cs.bsu.edu/homepages/pvg/misc/uml/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在另一个类中创建一个类的对象,UML类图中的关系是什么? - Creating an object of one class in another, what is the relationship in a UML class diagram? 它在创建另一个对象时创建的类和对象的UML关系? - UML relationship of class and object it creates inside the creation of another object? 对象返回和声明的UML类图 - UML Class Diagram of an Object Return and Declaration 我怎样才能证明一个方法在 class 图(UML)中是同步的? - How can I show, that a method is synchronized in class diagram (UML)? UML 类图,如何显示一个类扩展线程? - UML Class diagram, how to show a Class extends thread? 如何在MyEclipse 10颠倒的UML类图中显示类的属性? - How show the attributes of class in the UML Class Diagram reversed by MyEclipse 10? 如何将 object 从一个 class 存储到另一个 ZA2F2ED4F8EBC2CBB4C21A29DC40AB6 的 arraylist 中 - How to I store an object in an arraylist from one class in another class 在UML类图中,如何指定类的实际类型? - In a UML Class diagram, how do you specify Actual type of a class? UML Class 图:Object 通过构造函数关系? - UML Class Diagram: Object passed through constructor relationship? 创建列表的对象和类之间的 UML 关系,但在方法中添加对象 - UML relationship between object and class that creates list, but adds objects in method
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM