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:
How would I represent this kind of relationship in a UML class diagram?
Thanks.
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.
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.
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.
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.
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»
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With