UML

Published:
August 2, 2024

Here are my notes on the useful parts of UML, for when I write technical documentation for software.

Of course, UML diagrams aren’t the only solution for modeling software systems. Still, they provide a good set of symbols and conventions for those times where I actually have to make a diagram and I don’t want to search the web for How to make flowchart or sequence diagramming method.

Every time I search for a specific diagramming method, I see ten different ways of doing the same thing, depending on which authority on electrical engineering or otherwise you ask. And sometimes, you just want a thing that works, and not more.

Behavioral diagrams

Sequence diagram

These are great for modeling protocol interactions and other asynchronous and concurrent processes where the main focus is on what messages are being sent where. These are very similar to message sequence chart. I was happily using MscGen before, since it has SVG and PostScript output, which is useful for HTML or LaTeX-based typesetting. MscGen is not using a wholly standardized set of diagram elements, though.

State diagrams

Everything I create in my line of work sooner or later becomes a state machine. And most of these state machines go beyond the simple university examples. Take for example a backend server that maintains many active connections to database servers, caches, object storage services, and so on. Each connection state has to be managed accordingly, and not every type of failure stops the world, but some do.

In computer science, nondeterministic finite state machines are defined, roughly, as a Cartesian-like product of all the possible states that can be evaluated ‘concurrently’ (but not really), until the finite state machine hits the one lucky case that gets it to the finish line.

Having nested state machines is similar to that. Instead of defining the state of the server as a Cartesian product of all the sub states, these states can be tracked independently and in an interdependent way, where necessary.

Now that more and more language support algebraic data types (ADTs) as a first-class citizen, modeling ideas as finite state machines and having the type system support this is pleasant. For example, TypeScript has the | and & combinator for types. And Projectify makes heavy use of ADTs in Typescript, in order to implement type-safe state machines.

Activity diagrams

Activity diagrams are standardized flowcharts. Very useful.

The rest, I haven’t tried yet:

Structure diagrams

These are not really worth it. Perhaps deployment diagrams are worth a look, but for anything else, an entity relationship (ER) diagram is more than enough.

For Django, Django-extensions can create ER diagrams for the models used in an project. Sooooo useful!

As for the remaining structure diagrams:

Can we model UML in UML? At least that’s what one of my professors in uni said was the next exciting thing to happen in software engineering (and not figuring out how to prevent the next memory bug in Google Chrome).

These (structure diagrams) aren’t the diagrams you are looking for. Move along.

Summary

As you can see, I am much more interested in modeling the data and then defining as much interesting behavior for that data, as possible. This is a very conscious departure from old academia-brained me, where everything was objects talking to each other and passing messages, and that sounding really cool, like I was creating a multi-agent simulation in my computer and little robots were going about and working for me.

Far from the truth. Leaving the heavy lifting to the data model, and then figuring out how to safely map one piece of data into another for eternity is just so much easier to understand. Now that I am a grumpy developer with a not-yet graybeard, I humbly make way for the next generation of enthusiastic 19-year olds who too are completely fascinated by object oriented programming, because academia and globocorps shove it in their faces.

I would be thrilled to hear from you! Please share your thoughts and ideas with me via email.

Back to Index