Sequence diagrams are an invaluable tool when it comes to documenting different parts of a system and the various ways these parts interact with each other. They describe the operations within a system and map what and when messages are sent, providing a clear visual representation of the flow of information.
In their simplest form, sequence diagrams can model the messages and flow between a user and their bank as they log in to the banking app. However, in more complex forms, they can include alternatives, options, and loops to model conditional and divergent flows, such as a login process that includes security, verification, and other user actions.
Despite their usefulness, sequence diagrams are often overlooked and underused. They are often associated with the now rarely used Unified Modelling Language (UML) from the late 1990s. However, sequence diagrams have survived the test of time and remain a valuable tool in modern software development.
The Rise and Fall of UML
UML was originally developed by Rational Software in 1994 and was accepted as a standard by the Object Management Group (OMG) in 1997. The primary purpose of UML was to eliminate the chaos and confusion that had overtaken graphical modeling languages in the object-oriented world.
The rise of UML saw both excitement and criticism. Many loved it, but many either had problems with UML itself or with how people were using it. In the years since, several obituaries have been written, citing UML's complexity and its association with burdensome and often wasteful pre-work as the reasons for its downfall.
UML's Life Beyond Death
Despite its downfall, UML has had a surprisingly powerful life beyond death. A 2014 study showed that most of the developers and software architects surveyed were creating sketches and diagrams that contained at least some UML elements.
Occasionally, the topic comes up directly, and people still recommend learning a few UML techniques, with sequence diagrams being chief among them. One user even wrote that "The reward of the clarity of sequence diagrams is worth the pain and boredom of learning all the others at university."
Sequence Diagrams Out of the Ashes
Sequence diagrams survived not just because they were the best of a bad bunch but because they are genuinely useful. They provide a simple way to map and visualize the dynamic flow of messages across a system.
The primary use cases for sequence diagrams are:
- Sketching and designing how a system is supposed to work before building it.
- Documenting the requirements of a new system.
- Breaking down and understanding an existing (often legacy) system.
Sequence diagrams really shine when you're documenting different parts of a system and the various ways these parts interact with each other. However, they don't work as well when you're trying to model an algorithm in a specific system. If you get too granular and too detailed, sequence diagrams become too much trouble than they're worth.
Design Sequence Diagrams from the Inside Out
The best way to make a sequence diagram and solve the original problem is to start from the inside and work your way out and through.
Start with the Happy Path and Work to the Edge Cases
When creating a sequence diagram, it's best to start with the happy path - the ideal way messages flow from beginning to end. Once you diagram this core sequence, you can work outward to other routes and more infrequent message flows.
Comprehensibility > Comprehensiveness
The most common failure mode for sequence diagrams is over-complication. It's essential to strip away some information so as to clarify other information. Comprehensiveness is the enemy of comprehensibility.
Big Picture > Details
If the former problem is a result of being too comprehensive and too broad, the next problem is a result of being too detailed and too narrow. If you're building a sequence diagram to better inform design requirements, there's a point in the process where it's more efficient to stop diagraming and start coding.
Embrace an Architectural Mindset with Sequence Diagrams
Sequence diagrams are not only an artifact of UML but an artifact of a software design mindset that emphasized rigorous designing and planning. They help you create better sequence diagrams and better see the possibilities that result from having diagramming skills in your design and documentation arsenal.
In conclusion, sequence diagrams are a valuable tool in modern software development. They provide a clear visual representation of the flow of information within a system, making it easier to understand and improve the processes at hand.
Find more examples of how architects use sequence diagrams here
Try ZenUML now!
Zenuml detailed feature roadmap available here.