Top Cat
Top Cat

Reputation: 351

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 creates an instance of ServerLogic, and invokes the "run" method in ServerLogic. 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.

Here is an image of the two classes I'm talking about:

enter image description here

How would I represent this kind of relationship in a UML class diagram?

Thanks.

Upvotes: 5

Views: 6221

Answers (2)

nhouser9
nhouser9

Reputation: 6780

Represent it as a 1 to 1 relationship where ServerLogic is a dependent class of ServerThread.

Here is general info on UML if you need that: http://www.cs.bsu.edu/homepages/pvg/misc/uml/

Upvotes: 0

Christophe
Christophe

Reputation: 73456

I understand that your ServerThread and ServerLogic are structurally independent: no reference between each other is maintained. 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».

enter image description here

Upvotes: 8

Related Questions