-4

I try to design a client application for a messaging application. The client can send and receive messages, the client can connect/disconnect.

My problem is that I don't know how to incorporate the Server class. Where would one put it in the diagram?

John Smith
  • 55
  • 9
  • 1
    Since client and server are logically seperated anyway, why don't you create a second class diagram showing the design of the server? – helb Feb 06 '20 at 12:42
  • @helb, how do you mean? I don't know where to put the Server class in my current UML diagram. – John Smith Feb 06 '20 at 12:49
  • @helb Every communication with the Server happens through the ConnectionManager. – John Smith Feb 06 '20 at 12:51
  • 1
    It is usually a bad idea to put everything into a single diagram. Just created additional diagrams, showing other parts of your design and have one overview diagram (e.g. component diagram). – helb Feb 06 '20 at 12:53
  • @helb, how do you suggest exactly? – John Smith Feb 06 '20 at 12:55
  • @helb, so I cannot make an association? "Every communication with the Server happens through the ConnectionManager." – John Smith Feb 06 '20 at 12:56
  • @helb, *connect()* method sends a message object to the Server, notifying the server that the client is connecting. – John Smith Feb 06 '20 at 12:57
  • 1
    None of your classes directly depend on a server class. And this is good, since you are designing the client side which is separated through a network connection with the server code. Why do you want to insert server-side classes in this diagram when there are no dependencies? – helb Feb 06 '20 at 13:03
  • @helb, exactly as I thought. But, in a sequence diagram, I am trying to add the **Server delivers a message to the connected client** and the **Server delivers a message list with the connected users**. – John Smith Feb 06 '20 at 13:06
  • 2
    That's what sequence diagrams are for. You drew a class diagram (which is fine!). Create a new sequence diagram and draw the message flow between client and server. – helb Feb 06 '20 at 13:07
  • @helb, can I send you my sequence diagrams? – John Smith Feb 06 '20 at 13:08
  • 1
    No. Try asking a new question about your sequence diagrams. Good luck and have a nice day. – helb Feb 06 '20 at 13:09
  • @helb, how would you suggest? Thanks for your valuable confirmation so far. – John Smith Feb 06 '20 at 13:15
  • @helb, so I can still include **Server** even if it is missing from the UML class diagram? – John Smith Feb 06 '20 at 13:17
  • 2
    There is some ambiguity in your question: are you modeling an application that manages a datacenter (the server is a subject of your problem space) ? Or are you trying to model the system architecture (the server is a component of your solution) ? Is it about hardware servers or application backend? - i didn’t downvotes, but: you should make a specific title (so that others could recognize they have a similar problem) and make an introductory sentence about the purpose of your model (i.e what does it show and what are you making it for) – Christophe Feb 06 '20 at 14:57
  • @Christophe, it's a "Messaging System"! – John Smith Feb 06 '20 at 15:05
  • @Christophe, the client can send and recieve messages, the client can connect/disconnect. E.g. When the user logs in, a Connect is performed to the server, by also sending a Message telling the server that the client has connected. – John Smith Feb 06 '20 at 15:11
  • 1
    @JohnSmith thanks, the title starts to make things much clearer. Let me as otherwise: 1) is your server an entity, for example used in the addressing of your messages or as data for your ConnectionManager? 2) or is the server the “thing” on which the application will be executed? – Christophe Feb 06 '20 at 15:14
  • @Christophe, imagine a chat application, where you can see who is online etc. The ConnectionManager connunicates with the Server. So this means, that ClientApplication uses it, the user uses ClientApplicationUI interface. – John Smith Feb 06 '20 at 15:17
  • @Christophe, "1) is your server an entity, for example used in the addressing of your messages or as data for your ConnectionManager?" **YES**! – John Smith Feb 06 '20 at 15:20
  • @Christophe, I am only concerned with the Client Side part. Trying to design it. And thought about input from outside. – John Smith Feb 06 '20 at 15:21
  • @Christophe, my email address: so.john.smith.94@gmail.com . – John Smith Feb 06 '20 at 15:22
  • 1
    @JohnSmith Ok, let’s narrow this down: 1) can you confirm that the application runs on a client and not on a server? 2) can the client application interact with different servers (eg a chat on server1, another on server 2)? 3) is the server a software that you write, ie that would have properties and associations as your application does? Please answer each of these 3 questions. – Christophe Feb 06 '20 at 15:26
  • 1) can you confirm that the application runs on a client and not on a server? **YES!**, it runs from client machine and connects to a Server to auth and tell the server that the client has connected by sending a **Message**. 2) can the client application interact with different servers (eg a chat on server1, another on server 2)? **No answer here**. 3) is the server a software that you write, ie that would have properties and associations as your application does? **I am NOT writing anything currently. This is JUST Design UML**. – John Smith Feb 06 '20 at 15:37
  • 2
    I think the mismatch is that you are expecting to design a system but the diagram is an entity relationship diagram. Your system isn't fully described by a single entity relationship diagram. You need to use other methods and diagrams like describing the modules and interfaces (how they interact) and a data flow diagram. – Martin K Feb 06 '20 at 18:36
  • @qwerty_so. please see my latest **Edit**. ;-) – John Smith Feb 08 '20 at 13:05
  • @qwerty_so, please explain? – John Smith Feb 08 '20 at 14:39
  • @qwerty_so, I added the functions explanation to let anyone better understand this. Not sure what there is to joke about. Seriously. – John Smith Feb 09 '20 at 09:55
  • @qwerty_so, I am trying to make **two sequence diagrams**, using **this UML diagram** to show: **Server delivers a message to the connected client** and the **Server delivers a message list with the connected users**. Apparently, as **@heb** wrote, one can achieve this with sequence diagram *without having* the **Server** class in the current UML. – John Smith Feb 09 '20 at 10:30
  • @qwerty_so, *I shouldn't concern myself with "how the connection manager actually communicates with the Server.* – John Smith Feb 09 '20 at 11:11
  • @qwerty_so, see the added **sequence diagram**. – John Smith Feb 09 '20 at 11:37

1 Answers1

2

Issues in your diagram

You use the ECB pattern with «entity», «control», «boundary». This approach is meant to map classes to a use-case:

  • «control» would be a use-case, so a user goal. But CLientApplication does not represent a goal at all: it represents a component.
  • «entity» would be the domain objects (in general persistent). This would be ok for User if you mean the user record/account, and is fine for Message.
  • «boundary» are the association between the use-case and external actors. ClientApplicationUI is acceptable for this purpose. ConnectionManager could perhaps fit this description if the server to which it connects would be external to your system but represent a secondary actor (i.e. if it's not just the server hardware or operating system, but if it is a server application that is relevant for the user).

Way forward with a class diagram

The way to add the Server in the class diagram depends on its role. Is it:

  • the external system? Then, there is no need for it: external means that it should not appear in the class-diagram at all. It's like the primary actor: we know it exists but it's external to the system and not a class of the system (see also this similar case in another question) .
  • an internal object used by ConnectionManager for keeping track of server address, state, etc... ? Then add a Server class associated to the connection manager. But it's not really an «entity», nor a «boundary». It's a very technical class needed for the implementation.
  • a proxy for the server, i.e. a kind of representative of the external server that channels all the dialogue with the server ? Then Server would be a boundary class. But what would be the role of the connection manager then ? Connection manager would then act as a «control».

Select the option above that suits best your case. All the suggestions made are correct from point of view of the robustness matrix. This being said, I'm not sure that the ECB classification is helpful in your case. It raises more question and creates more ambiguity than necessary.

However, if you have to be fully compliant with the UML specs, you'd better leave them out (both the primary actor and the server).

Alternatives

I wonder if a component diagram could not better represent what you try to show here. In this case you could have two interconnected main components: ClientApplication and ServerApplication: The server would stay a black box component (since you focus on the client). The client would be composed more or less of your current classes. Components are classifiers of the system under consideration, so you can use them in sequence diagrams exactly as any other classifier.

John Smith
  • 55
  • 9
Christophe
  • 74,672
  • 10
  • 115
  • 187
  • Interesting. I shouldn't concern myself with "how the connection manager actually communicates with the Server" ... I hope **this** clears things up! – John Smith Feb 06 '20 at 21:17
  • 1
    @JohnSmith I think this strengthen the case for the component diagram: the components are also classifiers and may appear in a sequence diagram. Rhe component diagram allows to show the interfaces offered and consumed. You can the use in the sequence diagram the messages that you exchange with the interface. – Christophe Feb 06 '20 at 21:33
  • But, this I need to use a **UML Class Diagram**, I know where you are coming from. @Cristophe. – John Smith Feb 06 '20 at 21:49
  • I know that UML Class Diagram <--> Sequence Diagram must reflect each other, meaning that whatever is in the UML, must appear in Sequence Diagram, which I am sure you already knew. This is why I am confused. Because, I've been told that the **Server** system is already complete. You focus on Client side only. – John Smith Feb 06 '20 at 22:28
  • 1
    @JohnSmith I'm affraid that no, they don't. An UML diagram is not an UML model: it is a view on an UML model. So in the real world, diagrams are rarely comprehensive. You chose which elements deserve being shown in which diagram. But if you have to use a class diagram and if you have to show a server, I'd suggest ro go for the third bullet of the way forward, but use «subsystem» instead of «boundary» – Christophe Feb 06 '20 at 23:13
  • 1
    @JohnSmith I've had a second look at your sequence diagram and made some edits to my answer. Hope this helps. – Christophe Feb 09 '20 at 13:36
  • If you show me that, and it is valid. I will give you 50 points and mark this post as an answer. – John Smith Feb 09 '20 at 14:04
  • 1
    @JohnSmith it's just a secondary actor. An actor is not necessarily a human, it can also be an external system, provided it's relevant to the users and not an implementation detail. I think this is the case here. For the validity, it's common accepted practice to show actors on a sequence diagram, even if it's not legal UML (UML states that the lifelines must correspond to classifiers of the system under consideration). See edit with graphical illustration – Christophe Feb 09 '20 at 15:18
  • You mean like a empty rectangle with the text "Server", right? – John Smith Feb 09 '20 at 15:21
  • 1
    @JohnSmith with an UML profile you may lake any symbol valid for this purpose. But using standard notation, it would be an actor symbol, since UML makes no differnce between human and system actors. – Christophe Feb 09 '20 at 15:24
  • So, for you last reply, you mean like this: https://www.unimrcp.org/ea/index.htm?goto=3:4:2:4:276 – John Smith Feb 09 '20 at 15:26
  • 1
    @JohnSmith yes, this is exactly what I meant. And yes, the self call is valid. This means that the [execution occurence](https://www.uml-diagrams.org/sequence-diagrams.html#execution) started upon receipt of the `Connect` messages does things among others calling one of its own method (and hence the overlapping execution). However, you do not need to show this level of detail if you don't need it. – Christophe Feb 09 '20 at 15:32