Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 319
Top Cat Avatar asked Apr 03 '16 15:04

Top Cat


People also ask

What is the type of UML diagram that shows the object classes in the system and the associations between these classes?

Class Diagram Class diagrams are the main building block of any object-oriented solution. It shows the classes in a system, attributes, and operations of each class and the relationship between each class.

How do you represent an object in UML class diagram?

In UML, a class represents an object or a set of objects that share a common structure and behavior. They're represented by a rectangle that includes rows of the class name, its attributes, and its operations.

What is a diagram used to describe the relationship between classes and objects?

Class diagrams are the blueprints of your system or subsystem. You can use class diagrams to model the objects that make up the system, to display the relationships between the objects, and to describe what those objects do and the services that they provide. Class diagrams are useful in many stages of system design.

What does a UML class diagram show?

In software engineering, a class diagram in the Unified Modeling Language (UML) is a type of static structure diagram that describes the structure of a system by showing the system's classes, their attributes, operations (or methods), and the relationships among objects.


1 Answers

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

like image 135
Christophe Avatar answered Nov 15 '22 06:11

Christophe