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.

Friends and family claim I have an annoying habit of answering a question with a question. They think I'm being difficult, and they think the answer I deserve is a kick in a tender spot. But I have a reason: I’m convinced that the answer to most useful questions is: It depends. The best answers depend not just on the question, but on the context.

So when people ask me “I want to learn UML, where do I start?”, my answer is, “Where are you stopped?” Well, OK, my first answer is, "My UML Applied Class." But after I make the obligatory shameless plug, I have to know where your current project is. UML is a communications tool, not a technology, so it's useful across the complete application lifecycle; but different diagrams are more generally useful at different stages of the lifecycle.

In the UML Applied classes, we'll start with use cases, which is a great place to start at the onset of a project. If you just can't get started writing code because no one is sure what to write, use case diagrams will help you to capture user requirements and communicate them to stakeholders for feedback. Draw an actor, add use cases for that actor, and then add collaborating actors or related information for each use case. Repeat for each actor and use case until everyone agrees that you've identified the significant tasks that users must perform.

Stable Use Cases

If you're trying to learn and extend an existing, unfamiliar system, you might want to start by creating a component diagram that shows the existing components and the interfaces through which they communicate. From there, you can determine where your new code will fit within this architecture. You can also use these diagrams to plan out entirely new architectures.

Stable Component Diagram

Or you might start with a broader scope: a deployment diagram that shows where within a network the existing components are deployed. Again, you might also use these to plan a brand new deployment architecture.

Stable Deployment Diagram

Yet another way to learn existing code is to read the code and create sequence diagrams. A sequence diagram shows how parts of the code call other parts of the code to carry out user requirements. To learn how a particular user input -- say, a button click -- is processed, start with a lifeline that represents the form where the button click occurs. Read the button handling code, and add a self-message that describes any code within the handler. When the handler calls a method of another object, add a lifeline for that object, and then add a message from the form to the object, and label it with the method name. Repeat until you have diagrammed the entire handler. And then repeat for each call and method you have added, until you have a detailed view of how the handler works and how it collaborates with other objects.

Stable Sequence Diagram

I should add: the upcoming Visual Studio Team Systems 2010 (codename Rosario) will reverse engineer sequence diagrams straight from code!

Our final example today is when you're trying to understand or plan out the user interface flow of a system. For that, I like to use state diagrams, with each state representing one page within the user interface.

Stable State Diagram

By no means are these the only ways to start using UML. You name a diagram type, and I'll tell you about a time where I started work with that diagram. But these are the ones I start with most often. I hope they'll help you get started, too.

Posted on Saturday, November 15, 2008 3:10 PM VSTS 2010 (Codename Rosario) , UML | Back to top

Comments on this post: "Where do I start?"

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

Copyright © Martin L. Shoemaker | Powered by: