Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UML2: ports and interfaces in component diagrams

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

I. Imagine a piece of software which wants to use a very special remote logger service over network (TCP). The messages may be some XML. So the logger exposes an interface which specifies things like handshake, XML structure, XML elements etc. so that the logger will accept a message.

enter image description here

a) Am I right that this interface may be called "ILoggerProtocol", the port may be named after the service it provides ("logging")?

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

c) Now an interesting thing: for the communication, there is an additional library "Networking" which provides simple TCP stuff, so it does the TCP connect, sends messages, handles errors etc. Do I need this class when I only want to emphasise the way from the generated messages to the server? Is then MY port the TCP interface?

d) And when I want to draw the complete picture, how can I add the Networking component to the diagram correctly, pointing out that ILoggerProtocol is used AND that it goes over TCP through the Networking component?

II. Ports inside my application: now there are two libraries where one just uses the other; basically, in C/C++, it would #include the other's header file:

enter image description here

e) Is that the correct diagram?

f) Do I need ports here? If yes, what would they actually represent in reality? What names would you give them?

g) Or are the lollipops just sufficient without the port symbols?

III. concerning lollipops:

enter image description here

h) are those two notations basically the same and interchangeable? I have found the name "assembly" for the combined version, so maybe there is a difference...

like image 400
Ingmar Avatar asked Jul 29 '15 16:07

Ingmar


1 Answers

A short answer first (trying to rip up the rest later): a port is an embedded element which allows to group a number of interfaces. The best I can come up for an example is a complex socket (the port) which bundles things like power supply, communication lines, you name it (the interfaces).

Now for the details.

a) Yes, that's correct. You would usually use a <<delegate>> stereotyped association to show that the outer interface is used(/realized if it's a lollipop) somewhere inside.

b) No. This is a required interface. It is used inside but implemented outside (where the lollipop resides).

c&d) I'd use a <<use>> from MyApplication towards Networking to show that. Normally you would not go into too much detail (unless it is essential). Obvious things like TCP are clearly pictured with the <<use>>

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

f&g) see the general answer above

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

P.S. Just looking over this once again and I notice that in the top picture the inner directed association should be pointing the other direction and be stereotyped <<delegate>>.

like image 78
qwerty_so Avatar answered Nov 01 '22 06:11

qwerty_so