Model data flow from (flow) port to UML activity diagram - uml

One of the projects I am working on uses flow ports to model data flow between classes. We now started to model dynamic behavior using activity diagrams and state charts and are looking for a way to express that the data used in an activity diagram has been received on a specific port. Bascially, we want to create a connector between a flow port and e.g. an activity parameter node.
I think modelling data flow with ports is quite common especially in System Engineering, and there should be ways to link the data to activities. I can think of two some ways:
Connect the port to a property (or part) and use a ReadStructuralFeatureAction to get the value
Connect the port to a property (or part) and add an operation to the class which is called with a CallOperation
Create an attribute with the same name as the port and provide an operation that is called with a CallOperation action
The first option would be ok, but our modelling tool Rhapsody 8.1 seems to not support ReadStructuralFeatureActions. The other two approaches have the drawback that there is no direct connector between the port and the activity in the model and it is not visually obvious, so I would like to have a better alternative.
I am wondering if there anybody knows of better approaches to achieve this, e.g. using SysML (1.3).

The connections between the static and the dynamic views in UML and SysML are "hidden" in the less visible part of the model. I guess the reason is that the designers of UML wanted to separate these. So there are no graphical or otherwise very explicit connections.
Instead, the connections are quite natural, so you can just use it. Examples are the guards, triggers or actions on transitions in state charts or activity diagrams. This ReadStructuralFeatureAction is implemented implicitely by using the static element directly. You can modell them directly there. So they occur next to the edge that represents the state transition or control flow. A futher way is to use Receive Actions and set the property of the reception to an event or an triggered Operation. By using Send Actions you can trigger Events in the same structural element or others. When doing so in Rhapsody you need to specify the target Port and the target part.
Neither in UML/SysML or Rhapsody it is foreseen that you want to know via which port the call came or the attribute was changed, when you offer the interface of the Class/Block. But you can realize this by using full ports and implement the intended behaviour (which sould be distinctive - otherwise it would not be needed to know the source). So each full port has a state chart or activity and passes internal signals or events the object of your class. For calling operations from actions there are two ways, the more hidden one by just calling from the actions (or state on enter or leave) and the more visible one by using call operations.
The visibility of these connections have been changed in recent UML or SysML versions. So this will change significantly when updating to later Rhapsody versions; although I would really recommend to update to the latest Rhapsody version, as it brings better sysML support, far less bugs, a few new features and better usability.

Related

understanding dependency relationship in UML component diagram

I'm struggling at understanding UML component diagram.
I've just been through the "assembly connectors" and here's what I (think I) understood:
the circle represents an interface, which I understand as a set of functions that a component can offer to the others.
the half-circle... well, don't know how to call it, but it says something like "there's some functions I need in order to operate correctly". In the image, I guess that an order must have access to functions that return details of the Customer (e.g: methods GetName(), GetAddress(), etc.), that's why it has the assembly connection with the Customer Details interface, provided by Customer.
My question is: why is there a dependency relationship arrow from the interface which Account provides (AccountDetails) and the interface which Order requires (Payment)?
The link of this image doesn't explain it.
The assembly connector (two shown on top) is a kind of provisional concept. You know that there should be an interface used instead, but have not yet made up the details. This is a connector which looks like socket/lollipop. But it's a connector.
The separate lollipop/socket are concrete interface uses. These are real elements. The interface itself is not actually shown (you will have a separate diagram showing the details). But to make clear that the depending interface is related to the providing one you draw a dependency.
Simply spoken, the above is something in the middle of a design phase. Finally all assemlies should be replaced by provided/required interfaces.

How to keep domain model pure using ES approach?

I have flicked through few popular Event Sourcing frameworks written in a variety of different common languages. I have got the impression all of them affect the domain models to a really high degree. As far as I understand ES is just an infrastructure concern - a way of persisting aggregate state. Of course, it facilitates message driven inter-context integration but in core domain's point of view is negligible. I consider commands and events to be part of the domain itself so it looks perfectly fine that aggregate creates events (but not publishes them) or handles commands.
The problem is that all of DDD building blocks tend to be polluted by ES framework. Events must inherit from some base class. Aggregates at least are supposed to implement foreign interfaces. I wonder if domain models should be even aware of using ES approach within an application. In my opinion, even necessity of providing apply() methods indicates that other layer shapes our domain.
How you approach this issue in your projects?
My answer applies only when CQRS is involved (write and read models are split and they communicate using domain events).
As far as I understand ES is just an infrastructure concern - a way of persisting aggregate state
Event sourcing is indeed an infrastructure concern, a kind of repository but event-based Aggregates are not. I consider them to be an architectural style, different from the classical style.
So, the fact that an Aggregate, in reaction to an command, generates zero or more domain events that are applied onto itself in order to build its internal (private) state used to decide what events to generate in the future is just a different mode of thinking and designing an Aggregate. This is a perfect valid style, along with classical style (the one not using events but only objects) or functional programming style.
Event sourcing just means that every time a command reaches an Aggregate, its entire internal state is rebuild instead of being loaded from a flat persistence. Of course there are other huge advantages (!) but they do not affect the design of an Aggregate.
... but not publishes them ...
I like the frameworks that permit us to just return (or better yield - Aggregate's command methods are just generators!) the events.
Events must inherit from some base class
It's sad that some frameworks require that but this is not necessarily. In general, a framework needs one mean of detecting an event class. However, they can be implemented to detect an event by other means instead of using marker interfaces. For example, the client (as in YOU) could provide a filter method that rejects non-event classes.
However, there is one thing that I couldn't avoid in my framework (yes, I know, I'm guilty, I have one): the Command interface with only one method: getAggregateId.
Aggregates at least are supposed to implement foreign interfaces.
Again, like with events, this is not a necessity. A framework could be given a custom client event-applier-on-aggregates function or a convention can be used (i.e. all event-applier methods have the form applyEventClassNameOrType.
I wonder if domain models should be even aware of using ES approach within an application
Of ES not, but event-based YES, so the apply method must still exists.
As far as I understand ES is just an infrastructure concern - a way of persisting aggregate state.
No, events are really core to the domain model.
Technically, you could store diffs in a domain agnostic way. For example, you could look at an aggregate and say "here is the representation before the change, here is the representation after, we'll compute the difference and store that.
The difference between patches and events is the fact that you switch from a domain agnostic spelling to a domain specific spelling. Doing that is normally going to require being intimate with the domain model itself.
The problem is that all of DDD building blocks tend to be polluted by ES framework.
Yup, there's a lot of crap framework in the examples you find in the wild. Sturgeon's Law at work.
Thinking about the domain model from a functional perspective can help a lot. At it's core, the most general form of the model is a function that accepts current state as an input, and returns a list of events as the output.
List<Event> change(State current)
From there, if you want to save current state, you just wrap this function in something that knows how to do the fold
State current = ...
List<Event> events = change(current)
State updated = State.fold(current, events)
Similarly, you can get current state by folding over the previous history
List<Event> savedHistory = ...
State current = State.reduce(savedHistory)
List<Event> events = change(current)
State updated = State.fold(current, events)
Another way of saying the same thing; the "events" are already there in your (not event sourced) domain model -- they are just implicit. If there is business value in tracking those events, then you should replace the implementation of your domain model with one that makes those events explicit. Then you can decide which persisted representation to use independent of the domain model.
Core of my problem is that domain Event inherits from framework Event and aggregate implements some foreign interface (from framework). How to avoid this?
There are a couple of possibilities.
1) Roll your own: take a close look at the framework -- what is it really buying you? If your answer is "not much", then maybe you can do without it.
From what I've seen, the "win" of these frameworks tends to be in taking a heterogeneous collection of events and managing the routing for you. That's not nothing -- but it's a bit magic, and you might be happier having that code explicit, rather than relying on implicit framework magic
2) Suck it up: if the framework is unobtrusive, then it may be more practical to accept the tradeoffs that it imposes and live with them. To some degree, event frameworks are like object relational mappers or databases; sure, in theory you should be able to change them out freely. In practice? how often do you derive benefit from the investment in that flexibility
3) Interfaces: if you squint a little bit, you can see that your domain behaviors don't usually depend on in memory representations, but instead on the algebra of the domain itself.
For example, in the domain model, we deposit Money into an Account updating its Balance. We don't typically care whether those are integers, or longs, or floats, or JSON documents. We can satisfy the model with any implementation that satisfies the constraints of the algebra.
So you can use the framework to provide the implementation (which also happens to have all the hooks the framework needs); the behavior just interacts with the interface it defined itself.
In a strongly typed implementation, this can get really twisty. In Java, for instance, if you want the strong type checks you need to be comfortable with the magic of generics and type erasure.
The real answer to this is that DDD is overrated. It is not true that you have to have one model to rule them all. You may have different views on the state of your world, depending on your current needs. One part of the application has one view, another part - completely different view.
To put it another way, your model is not "what is", but "what happened so far". The actual data model of your application is the event stream itself. Everything else you derive from there.

Linking activity diagram to entities to be accessed

How do we represent in an Activity Diagram, which entities are to be accessed or updated? Is this is to be done as part of an activity diagram, or to be done separately?
You specify which Classes are accessed or updated using Pins on an Action or using an ActivityParameterNode on an Activity. Those Pins look like little squares on the periphery of the Action, or rectangles on the diagram frame of an Activity, and you connect OutputPins to InputPins using ObjectFlows (which unfortunately look just like the ControlFlows that connect Actions together). Here's an example from the UML 2.5 spec:
Now, to answer what I think you are really asking. I think you want to know how to navigate to instances of Classes in your model. To do that from an Activity, you use a ReadStructuralFeatureAction to read properties from the Class instance that owns the Activity you're specifying. The values flow out of an OutputPin. Using ReadStructuralFeatureActions you can navigate anywhere your instances allow. (Note that when a Property is owned by an Association rather than a Class, you use one of the ReadLink*Actions specializations of Action.)
Please see Part 4 of Conrad Bock's excellent series, UML 2 Activity and Action Models,
Part 4: Object Nodes for a better understanding.
You can use either
a dependency (dashed line) or
an object flow (solid line) to show that an action is interacting with an object or
an information flow (stereotyped with <<flow>>). This way you can specify one or more classes which control the information that is flowing (in the example it is FileTypeObject).

How to elaborate information flow in large scale distributed system by UML

I am currently Designing UML Diagrams for a distributed backed made up of 8 nodes, which handle specific operations depending on the message received from the web Client.
The problem I have is that, the initial node which acts as the "Gate of Entry" to all messages and interactions generated from the Client-end, does not contain concrete operations that could be denoted as "Standard Use cases" but only a multitude of message flows pertaining to client-end use cases operations that flow throw this point.
But I also desperately require a method to show a process mapping between the client-end Use Case and initial node Use Case processes for consistency sake. If these messages are not mapped, the following the flow of operations from the Client-end to Server-end will be somewhat complicated.
Unfortunately due to the complexity of the system I have a problem of designing the whole System in a single diagram too.
Some Possible Improvisations considered
• To create "Place holder" like Use Case Ext. notation to indicate an extension.
E.g. The client-end has a place new order Use Case from which a message flows through initial node to the back-end nodes. In order to create connectivity indicate a Use Case which would read Place new order Ext. and this would signify a connectivity but would only point to a message flow.(But I am not sure if this practice is largely excepted in UML.)
• Only rely on Sequence and communication diagrams aim to show how "things" interact, each lifeline designating one of the system components. But I feel is that the correlation between Client-end and Back-end Use Case will not be very clear.
I also checked for similar problems on this forum and there were a few but did not explicitly answer my question.so I thought of posting this question.
Can someone please suggest what would be the best option in showing information flow in this highly event-driven distributed information system such as this - One of the above mentioned or any other options that I may have overlooked?
Have you considered using component diagrams, where the components have ports and the ports accept (and produce) signals instead of operations? A signal is basically a message / event.
You can also model signals as classes at the high level, or in as much detail as you need. You could model some of the properties of an application-level signal such that you can show how a component demultiplexes based on some property before forwarding the message along to an output port.

Is it possible to use ball and socket notation in EA class diagram?

Ball and socket notation is legal UML 2.0, but I cannot find a way to force EA to draw it on the diagram. It refuses to allow dependency between socket and the ball. Is there any way to make it happen, as in diagram below (little ms paint magic):
Also, a side question, can you make the ball or socket appear on the other side of the element?
There are two different ways of showing the ball and socket in EA.
With the one you've used, you've drawn connectors from your Consumer and Producer classes to the IProducer interface (a dependency and a realization, respectively).
You've then switched on display of Dependent and Realized interfaces on your classes.
Doing it this way means the balls and sockets are fixed. You cannot select them (the class gets selected instead), you cannot move them wrt their parent classes, and they cannot be endpoints for connectors.
The other way is to use Expose Interface.
With this method, you don't draw any connectors from your classes to the interface. Instead, you use Expose Interface to create an embedded element, which has the interface as its classifier, in each class.
These exposed interfaces, being elements in their own right, behave the way you want them to: you can move them around the perimeter of their respective classes, and you can draw connectors between them.
In the example, note the absence of any connectors to the IProducer interface element.
In order to expose the interfaces, there are two ways to go about it. You can select Expose Interface in the diagram toolbox, but note that that's only available in the Component toolbox - not the Class toolbox. That's what I've done with the Producer in this example.
The other way is to right-click the class and select New Element -> Port. This creates a port, which you can give any name. Then you right-click the port and select New Element -> Provided / Required Interface.
Either way brings up the Exposed Interface dialog, which allows you to select the interface element that should be exposed by using the ellipsis button (...) and browsing the project tree for interfaces.
Using a port may seem a bit cumbersome but it is, strictly speaking, more correct UML. Note also that a single port can expose several interfaces, both provided and required, allowing you to group interfaces which form some sort of logical unit. It might be that you have several interfaces which form one service and so go together, but that the class provides and requires several services.
This (to me) makes more sense when you're discussing not individual classes but rather components, and I generally use realization/dependency whan I'm modelling classes, and ports and exposed interfaces when I'm modelling components.
In EA ball and socket connections can (only) be drawn between ports. Use the "assembly" connector type.
It is right that ball and socket are legal UML 2.0 notation but they are not UML element, they depict element relations. So I guess that depending of the tool you use it will (or will not ) allow you to create a dependency between them. According to UML specification, a UML dependency should be create between, at least, two NamedElements.

Resources