Search code examples
javaumlinstantiationclass-diagram

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.


Solution

  • 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