Figure 4.4 shows a simple algorithm based on the following pseudocode: Figure 4.4. Both loops and conditionals use interaction frames, which are ways of marking off a piece of a sequence diagram. Treat sequence diagrams as a visualization of how objects interact rather than as a way of modeling control logic. If you want to show control structures like this, you are better off with an activity diagram or indeed with code itself. The first thing to point out is that this isn't what sequence diagrams are good at. A common issue with sequence diagrams is how to show looping and conditional behavior.