UML2: ports and interfaces in component diagrams

Since I have not yet fully understood the correct use of port and interface symbols in component diagrams, a few questions:

I. Imagine a piece of software that wants to use a very special remote registration service over a network (TCP). Messages can be some XML. In this way, the registrar provides an interface that indicates such things as a handshake, XML structure, XML elements, etc., so that the registrar receives the message.

enter image description here

a) Is it correct that this interface can be called "ILoggerProtocol", can the port be named after the service it provides ("logging")?

b) So, the component in my application implements this interface so that it generates a compatible message for the server?

c) Now an interesting thing: for communication, there is an additional library called Network, which provides simple TCP material, so it connects to TCP, sends messages, processes errors, etc. Do I need this class when I just want to emphasize the path from the generated messages to the server? Is MY port then a TCP interface?

d) And when I want to make a complete picture, how can I correctly add the Networking component to the diagram, indicating that ILoggerProtocol is being used, and that it passes through TCP through the Networking component?

II. Ports inside my application: now there are two libraries in which one uses the other; mainly in C / C ++, it will # include another header file:

enter image description here

e) Is this the correct diagram?

f) Do I need ports? If so, what do they actually represent? What names will you give them?

g) Or are there enough lollipops without port symbols?

III. regarding candy:

enter image description here

h) - are these two entries basically the same and interchangeable? I found the name "assembly" for the combined version, so there may be a difference ...

+5
source share
1 answer

First a short answer (an attempt to parse the rest later): the port is a built-in element that allows you to group multiple interfaces. The best I can think of as an example is a complex socket (port) that connects things like a power source, communication lines, you name it (interfaces).

Now for the details.

a) Yes, thatโ€™s right. Usually you used the stereotypical association <<delegate>> to show that the external interface is being used (/ implemented if it is a candy) somewhere inside.

b) no. This is a required interface. It is used internally, but sold externally (where the candy is located).

c & d) I would use <<use>> from MyApplication to Networking to show this. Usually you donโ€™t enter in too much detail (unless this is required). Obvious things like TCP are clearly depicted using <<use>>

e) You can (/ should) use <<include>> or <<use>> instead.

f & g) see general answer above

h) Yes. The first is a flexible recording of the second.

PS Just look at it again, and I noticed that in the top image, the internal directional association should point to a different direction and be stereotyped <<delegate>> .

+5
source

All Articles