[英]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. 我知道您的ServerThread
和ServerLogic
在结构上是独立的:不保持彼此之间的引用。 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»
从ServerThread
到ServerLogic
绘制依赖关系(带箭头的虚线)。
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.