Geeks With Blogs
Ulterior Motive Lounge UML Comics and more from Martin L. Shoemaker (The UML Guy),
Offering UML Instruction and Consulting for your projects and teams.

In our last Episode, Linguist Coder and Prototype Analyst kidnapped The UML Guy and demanded he explain arrows in UML. After a rescue by the police, The UML Guy returns to the Lounge. (Click the picture for a larger image.)

Episode 23

This one is for Jennifer Marsman, who is quite possibly the second-most-fanatical UML geek that I know. She's also the creator of Featured Women in Technology, an ongoing series of profiles on women who shine in technology fields. Jennifer does her part to show young women that technology isn't an all-men's club. And boy, is she right! Besides her profiles of Dianne Marsh, Katy Kneale, Janet Galore, Carey Payette, Amity Binkert, and Lidiane Souza, I would add (off the top of my head) Lynne Molenkamp, Dana Coffey, Michelle Leroux Bustamante, Mary Poppendieck, Julie Lerman, Betsy Weber, Sarah Dutkiewicz, Anne Gogh, Gina Loveless, Grace Hopper, Rachel Appel, Janine Moore, Maggie Longshore, Elizabeth Naramore, Lynn Langit, Jennifer Davis, and Kirstin Juhl. Plus many more whom I forget at the moment, but whom I respect as colleagues, and to whom I offer my sincere apologies for my feeble memory. And lest we forget, Jennifer Marsman.

The Lounge is a bit testosterone heavy so far. Partly due to the characters I used as inspirations, partly no doubt from my own experience, the Lounge cast so far has run about 7 males per female. I decided that was out of balance (although honestly, it's a better ratio than most places I've worked); so it was time to add Geek Girl to the cast. Think of her as a spokesperson for all the engineers and designers and evangelists and authors and speakers in the list above. With Crystal Bernard's accent, because Wings happened to be on while I was drawing this Episode. (It's amazing the tricks the mind plays. I could "hear" Geek Girl in my head, clear as a bell, and couldn't place the voice, even as the same voice was speaking in the background.)

Modeling user interfaces in UML is a common problem; and State Diagrams are easily the best answer I've found. They're a great way to show flow that's based on user decisions, not on some algorithm. With Events and Actions, they're a great way to show control events and how your system responds to them within a given form.

And perhaps most important, they're a great way to handle The Cancel Problem. In a modern GUI, it's often the case that a user can cancel at almost any point. Even worse: if you're building a Web app, they can always just close the browser, or even disconnect from the Web. That's not an immediate cancel; but it will be a cancel when the Web session times out. If there's some work that has to be done to clean up when the user cancels, trying to draw control flow with Activity Diagrams, or even with State Diagrams, becomes a nightmare as you try to draw arrows from every possible cancel point to the clean up work. But with a Superstate that contains all of the cancelable Substates, you can easily show that all of these Substates handle cancel in the same way: by performing this clean up work. In today's Episode, for example, no matter where you are in the Booking process when you cancel, you have to go to Releasing, or the suspect will get lost in the system.

User interfaces aren't the only things you can model with State Diagrams, of course. They're a powerful tool for modeling certain kinds of business processes. In particular, if you have a document-centric process, where some document (such as an Order for goods) passes to different departments as different people act on it and different events occur, then you can easily automate that process as a document object that passes through different States in response to some Events, and which does work within a State in response to other Events. This can be a convenient way to model processes built within a Service Oriented Architecture.

Another value of State Diagrams is that a number of tools will turn these directly into executable code. In particular, Windows Workflow Foundation is a powerful tool that lets you graphically design both Sequential Workflows (similar to Activity Diagrams) and State Workflows, and then execute them directly. There's some work involved in hooking them into a user interface, but there's amazing flexibility and power in being able to depict and edit a flow graphically and then change your mind without having to change a lot of code.

Posted on Saturday, November 15, 2008 5:23 PM Ulterior Motive Lounge | Back to top

Comments on this post: Ulterior Motive Lounge Episode 23: Girls Just Wanna Write Code

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Martin L. Shoemaker | Powered by: