Reputation: 22244
If there is a way to capture actions or behaviors in a class diagram, if possible, e.g. creates the links at runtime for associations, or updating objects states.
In my understanding, Class Diagram is to capture static relationships, such as class X has-a class-Y as a member, or has a reference to class Z. Hence, I suppose capturing runtime actions or behaviors are not meant to be in a Class Diagram, but I wonder if there could be a way to inject the knowledge of what is happening at runtime among the objects of the classes.
For instance, in the diagram where I am trying to capture AWS ECS ER.
Docker Daemon creates the link between Container Network Interface and Host Network Interface with a docker run command "publish port".
ECS Agent sends command to Docker Daemon via Docker Socket but there is no direct has-a nor reference between them.
ECS Agent communicates with ECS Scheduler but the ECS Agent has no direct knowledge of the ECS Scheduler until the agent joins the cluster and get information.
ECS Scheduler updates the ELB Target Group to forward network traffic to the Host Network Interface.
Please suggest a UML way by which I can capture "publish port" or "update TargetGroup" in the class diagram, if any.
Please correct if any mistakes or incorrect usage of notations in the diagram. It would be highly apprciated.
Upvotes: 0
Views: 868
Reputation: 5673
UML is quite bad at integrating class modeling with behavior (i.e. event/action) modeling.
However, it is natural to model the actions of active objects (of type A
) in the form of operations in the corresponding class A
.
You could then express their effects (e.g., changing the value of a property of an object, or creating a new link)
When using an activity diagram, you could use partitions (or 'swim lanes') for representing your active objects.
Upvotes: 1
Reputation: 36305
Two answers (about the behavior):
Yes, you can do than.
No, you must not do that.
So what? Class diagrams are meant to show the static relations between classes. The reason for associations between classes exists only for a design reason. The architect has the feeling that due to a described (use case) behavior it should be that way. When that is settled (though not in concrete) you model the various behavior (either with activity or sequence diagrams) which illustrate certain collaborations realizing use cases. In the cause of this design step it can be necessary to adapt the static relations. And that might again affect the shown behavior. Or even can have the conclusion that the use case activities need to be adapted (and even the requirement can be proven to be not implementable the one or other way because...).
Rather than mangling the associations you could make activity diagrams with call behaviors or show messages within sequence diagrams created for collaborations.
A better way would be to put the relevant part of teh static class design additionaly on a SD or AD. As per UML spec you can (and should) mix all UML elements on all diagrams (if it helps communicating the design reasons).
For the ports: you will show them in component diagrams. A port is an element for a component and shows interfaces. These are usually delegated to classes inside the component realizing or requiring the interfaces. You will show ports as small squares on the border. I haven't seen them listed in the operations compartment (that's likely not correct). If at all textual you would need a separate compartment marked as "list of ports" or the like. Just putting them in one row with attributes isn't right.
Upvotes: 1