How to use an activity diagram to detail classes & methods? - algorithm

I wish to document code for a fairly complex algorithm whose implementation is intertwined across several methods and classes. A sequence diagram cannot really describe the detail of each method well so I am looking at an activity diagram; however this doesn't typically seem to represent classes and methods, only the logic.
Is there a common or even proper way to show which methods the logic belongs to? I do not need to follow strict UML, the purpose is simply to make it clear what's happening visually.

Activity diagrams and partitions
The activity diagram are supposed to models activities without necessarily relating them to classes/objects. They are however very suitable for modeling complex algorithms, as they allows to show :
the control flow -- flowchart diagrams have proven effective for modeling alorthims; activity diagrams are much more precise in their semantic and can do this as well.
object flows that show what objects are passed through
there are object actions that are specifically meant for dealing with objects
Activity diagrams support partitions, i.e. visual grouping of activities according to a criteria. A popular use is to split actions by using subsystems as grouping criteria. Breaking down by classes seems overkill, but nothing forbids such groupings if it helps, and if you're able to use it consistently.
Interaction overview diagrams
Interaction Overview Diagrams are specialization of Activity Diagrams that represent Interactions.
Interaction overview diagrams are a kind of combination of activity and sequence diagrams. The general idea is to use some activity modeling features for showing the big picture of the flows, between interaction nodes, i.e. mini sequence diagrams embedded in the larger diagram, to show which objects are involved and what messages they exchange.
There is an inspiring example here. But be careful: the linked website is based on a former version of UML and the text is not fully up-to-date. The most accurate source on these diagrams is section 17.10 of the UML 2.5.1 specs.
Additional thoughts
Instead of trying to show everything in one diagram, you may prefer the beauty of simplicity: use an easy to understand, simpler overview diagram, and uncover the complexity in additional diagrams that focus on details. This works with activity diagram complements with more detailed activities or sequence diagrams. But it also works the other way round, showing exchanges between key objects in a sequence diagram, and provide more detailed activity diagrams to describe what happens inside of one of the invoked operation.
Disclaimer: While I provide some hints that you can use to model algorithms in relation with their classes, I have at the same time to warn you that visual programming, i.e. a very very very detailed modeling, may lead to very complex diagrams that are difficult to read, and even more difficult to maintain. They loose the benefit of communicating the big picture. I'm not alone in this criticism, see Grady Booch who knows what he is talking about, since he is one of the co-inventor of UML, Martin Fowler, and many others

Related

Modelling logic

I have an interface (android activity, but that should not matter) with text input, spinners and a toggle button (all on one page). Depending on the state of all these elements I produce text output (on the same page).
Since the relationship is not trivial, I would like to somehow visualize the logic relationship between these elements. I am reading about UML, activity diagrams, etc but got a bit lost there.
What term should I look for? What program do you recommend to use for drawing such diagrams on computer (linux)?
UML Activity Diagrams might not be what you are looking for. They are usually used to model activities in a process. They tend to be more high-level and conceptual and less about the implementation.
From your question it reads as if you are working on the implementation itself. In that case I would urge you to look at UML State Diagrams. They are really neat when you want to think about different states your application (or components of your application) can be in. It also lets you logically decompose behaviour into states.
Furthermore, it is also a straight-forward way to model your application in a way that you can apply a Design Pattern, notably the State Pattern, to implement your model.

How to use UML for describing distributed tasks

I am preparing a presentation and want to show some UML diagrams which will tell about how my distributed program runs. Since UML is a common language in the software world, I thought that it is one of the best ways to tell about the things in my mind to the listeners.
The problem is that I don't know how I can use UML diagrams for some distributed tasks. Firstly, I want to use Sequence diagrams and show the distributed components as actors. It looks possible. But, how can I demonstrate mpi_reduce_all function in this diagram? And, how can I demonstrate asynchronous communication and then synchronization (i.e. after a while I run isend/irecv commands, I synchronize the processes using wait_all function)?
Is there any idea for this? Or alternative diagrams to demonstrate what I want?
Check uml-diagrams.org: UML Activity Diagram Examples. The Fork/Join node in UML Activity Diagram is explicitly designed to show parallel tasks and synchronization points.
For the purposes of a presentation consider BPMN. The Business Process Model and
Notation (BPMN) language is also common in the software world and is also backed by the Object Management Group (OMG).
Description of parallel tasks and data exchange and synchronization points is among it's strong features.
See also:
Bonitasoft: The Ultimate Guide to BPMN2

What are well known examples for models?

I'm currently writing a blog entry that is also about model-2-model transformations. I would like to explain shortly what a model-2-model transformation is in this post. Therefore I would like to come up with a simple example of two models, where the first is transformed to an instance of the second. Both models should be well known to developers, so that I don't need to explain them.
However I couldn't come up with some example models. ATL uses a family and person model in one of their tutorials, but they also require extra explanation as I think.
So do you know an example that I can make use of?
If you want to explain m2m to developers, you can use an M2M-trafo from petri nets to uml activity diagrams. Because activity diagrams are based on petri nets it should not be to complex. I think both models should be known by a developer. Sure, they are not easy, but a developer should know them.
http://en.wikipedia.org/wiki/Petri_net
http://en.wikipedia.org/wiki/Activity_diagram
Sure you should keep as simple as possible. This means you should only describe the transformation for a subset of modeling possibilities. For petri nets I only would use simple states and transitions as subset of the metamodel. For activity diagrams I only would use actions and transitions.
There should already be existing examples of this transformation, so you can also use existing knowledge.
Another thing I want to point out is, that someone how learns M2M-trafo understands what M2M-trafos are used for. Because this case described above can be used in practice.
I chose object relational mapping (ORM) as an example in my blog post. ORM can be viewed as a bidirectional transformation from a relational database model to an object oriented in memory model.
Most (every) developer should know about ORM. But the problem might be that this could cause devs to think about m2m in terms of Hibernate, JPA, etc, which is not the case.
As an example you may consider translation from one language to another. There is an example of translation from UML to OWL.

Which type of UML diagram is best suited to modelling form validation rules?

Would an activity diagram be the best way to express validation rules for an HTML form, using a whole bunch of decision nodes? I am not convinced that it is, but I can't find a more appropriate one, nor can I find any examples of validation rules models online.
None - no one in their right mind would create a graphical representation of form validation rules. UML is not the same thing as engineering drawings, in spite of the best efforts of its proponents.
You're doing it wrong if the effort required to create the UML diagrams for a system approaches that of actually developing the code. Better to have running code that you can actually unit test. The unit tests are better documentation than UML will ever be.
Don't try to represent everything in UML.
An UML diagram is good idea. Activity diagram can be created with graphical rules (e.g. pink annotation).
It is a good start even before codding.
For any non-trivial rule you´ll need to use a language like OCL to be able to express the rule.
Validation is fired in case of a misuse case so it Can be represented using activity diagrams. Sequence and activity diagrams also help you debug production issues and nail them quickly

Best way to model Installation logic/flow

We are currently working on designing the installer for our product. We are currently on the design phase and I'm wondering what is the best diagram (UML or not) to use when modeling installation logic or flow?
Currently, we are using the good'ol flowchart.
Thanks!
What problems are you having with the flowchart? Are you trying to model the functional flow of the application or the logic flow through the components of the system?
If you're just trying to show how the installer works from a functional perspective, then a flowchart is fine and has the advantage of being understandable by non-technical people.
But if you're doing a technical design, then probably you should use UML class and sequence diagrams. The class diagram shows the static relationships between classes, while sequence diagrams show how the classes interact to implement the functions of the application. You'll generally only need one class diagram but a whole bunch of sequence diagrams, because you need to work out the logic flow for each of the use cases that you've identified.
UML defines other diagram types that are all useful under limited circumstances, but class diagrams and sequence diagrams will get you 90% of the way home at least.
There's a diagram called a collaboration diagram that's related to a sequence diagram in that both show interactions between components. A collaboration diagram is what you create when you draw a bunch of boxes on a napkin and with arrows between them to show how components talk to each other. You may find that starting out with collaboration diagrams is easier.
This is a useful tool for making sequence diagrams:
http://www.websequencediagrams.com/

Resources