Vineeth B V
Vineeth B V

Reputation: 75

UML how to indicate one class sending request to same class

There are 2 classes in the scenario under consideration, User and ConnectionRequest.

The structures of the 2 classes are given below:

User:

ConnectionRequest:

A user can send a connection request to another user, or they can receive a connection request from another user such as on social media platforms.

What type of connection/relation do the 2 classes share?

How can this be represented using UML notations in a class diagram?

Any modifications or improvements to the above model ignoring other system requirements are welcome.

Upvotes: 2

Views: 97

Answers (2)

Christophe
Christophe

Reputation: 73446

This is tricky. If one user sends/receives a connection request to another user, but you want to use only one association, you’ll have a ternary association, with two ends for the same class User (once for the sender role, once for the receiver role) and one for the ConnectionRequest.

enter image description here

Alternative models could use either an association class ConnectonRequest of User to User, or two distinct association between User and ConnectionRequest each with a different set of roles. at both ends.

Upvotes: 1

Jim L.
Jim L.

Reputation: 6529

Change the type of sender and receiver from String to User, using two associations.

Upvotes: 1

Related Questions