Skip to main content

Web services programming tips and tricks: Drawing clean UML diagrams

Clarity begets adoption

Scott W. Ambler, Practice Leader, Agile Development, Rational Methods Group, IBM, Software Group
Scott W. Ambler is President of Ronin International, a consulting firm specializing in object-oriented software process mentoring, architectural modeling, and Enterprise JavaBeans (EJB) development. He has authored or co-authored several books about object-oriented development, including the recently released The Object Primer 2nd Edition, which covers, in detail, the subjects summarized in this article. He can be reached at scott.ambler@ronin-intl.com and at his Web site at www.ambysoft.com.

Summary:  Like it or not, software diagrams such as Unified Modeling Language (UML) class models and use case models, are often judged on their looks. Diagrams that look "clean" are more readily accepted by their audience -- often your users and senior managers -- than diagrams that look messy. This tip is derived from Chapter 3 of Building Object Applications That Work.

Date:  27 Nov 2000
Level:  Introductory
Activity:  1789 views

I would like to describe several important rules of thumb that will help you to distinguish yourself from your modeling peers. This simple, yet critical, advice focuses on how to arrange the bubbles and lines that make up your software diagrams -- including UML class models, use case models, and even persistence models -- and is therefore applicable to all kinds of diagrams.

To draw clean-looking diagrams you should avoid:

Let's begin by considering an example. In Figures 1 and 2, you see two diagrams drawn using two different styles. The first one is complex and disorganized while the second is simple and well organized (albeit a little boring). Which one looks like a better design to you? Most people would agree that the second one looks better because it is laid out in a cleaner way, although the fact is that both designs are functionally identical.


Figure 1. A "messy" diagram
A messy diagram

Figure 2. A "clean" diagram
A clean diagram

Avoid bubbles of different sizes

How did I improve Figure 1? First, I made sure that all the bubbles were of the same size. Larger bubbles appear more important than smaller ones, which is good if that is what you are trying to communicate -- but given the option, I prefer to make my bubbles the same size. This approach is best suited for UML Use Case diagrams where all the use-case bubbles and actor symbols can easily be the same, as well as UML Collaboration Diagrams, UML Sequence Diagrams, UML Collaboration Diagrams, and User-Interface Flow Diagrams. It becomes a little more difficult for diagrams where the bubbles contain varying amount of information, such as UML Class Diagrams where individual classes have different numbers of attributes and operations, or UML State Chart Diagrams and Persistence (data) models.


Avoid diagonal lines

Additionally, Figure 2 does not have any diagonal lines, unlike Figure 1. I did this by reorganizing the bubbles as if they were on a grid, keeping connected bubbles either vertically apart or horizontally apart. Straight lines are more visually appealing to most people.


Avoid crossed lines

In Figure 1 there are two lines that cross each other, and my general rule of thumb is that you should strive to minimize the number of crossed lines in your diagrams. By moving a few bubbles around, I could quickly avoid having the two lines cross. Unfortunately, you don't always get this lucky -- you can't always avoid crossing lines. In Figure 3, I would like to fully connect five bubbles but cannot do so without having at least two lines cross each other. As you can see, there is no other way for me to connect bubbles 3 and 5. When I am forced to have crossed lines, I will notate it using the standard applied on electrical-wiring diagrams: one line is drawn "hopping over" another one, as in Figure 4. The advantage of hopping is that it is clear that the lines are only crossing on your diagram, and that they don't connect in any way.


Figure 3. How do you connect 3 & 5 without crossing a line?
How do you connect 3 & 5 without crossing a line?

Figure 4. One line "jumps" over the other
One line jumps over the other

Avoid curved lines

I improved Figure 4 even further by removing the curved lines, as you can see in Figure 5. People like straight lines that are either vertical or horizontal. Once again I pretended I was drawing my diagram on a grid (this is actually a built-in feature of many computer-aided system engineering (CASE) tools), then I simply drew my bubbles and lines as if there were on that grid.


Figure 5. A cleaner version of Figure 4
A cleaner version of Figure 4

Avoid cluttered or complex diagrams

Diagrams that show too many details or that appear cluttered don't look good. It is better to have several diagrams showing various degrees of detail than to have one complex diagram that shows everything. This is one of the reasons why the UML has several diagrams: software is so complex you cannot hope to model all of its aspects on a single diagram. Furthermore, the UML allows packages to be added to diagrams (the topic of next week's tip).

A related consideration is the use of your screen or page real estate. In my opinion, one diagram spread out over several pages is better than a diagram with everything smushed together so it will print onto one page. You should take as much space as you need to make your diagrams easy to understand.


Avoid wasting too much time making your diagrams look pretty

Although these rules of thumb work very well, there is always the danger of adding hours to your modeling efforts by endlessly tweaking the way your diagrams look. One way to solve this is to try to get your diagrams looking good in a rough sort of way -- a diagram doesn't have to be perfect while you're working on it. Once you're satisfied that your diagram models the application the way that you want it to, then begin moving bubbles around to avoid crossing lines and improve its understandability.

Your main goal is to model the system, not to produce a pretty diagram. It is important to point out that you can use also these rules of thumb to make a bad design look good. For example, I could have started with Figure 2 and rearranged it into Figure 1 to make my design look more complicated than it actually is -- perhaps to convince senior management that I need more time or resources to do the work, or to steer them away from a design alternative that I don't particularly like. Given that your motivations change from situation to situation, I hope that your situation is happy enough that your greatest concern is to make a great design look spectacular, rather than to survive office politics.


Resources

About the author

Scott W. Ambler is President of Ronin International, a consulting firm specializing in object-oriented software process mentoring, architectural modeling, and Enterprise JavaBeans (EJB) development. He has authored or co-authored several books about object-oriented development, including the recently released The Object Primer 2nd Edition, which covers, in detail, the subjects summarized in this article. He can be reached at scott.ambler@ronin-intl.com and at his Web site at www.ambysoft.com.

Comments (Undergoing maintenance)



Trademarks  |  My developerWorks terms and conditions

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=SOA and Web services
ArticleID=11456
ArticleTitle=Web services programming tips and tricks: Drawing clean UML diagrams
publish-date=11272000
author1-email=scott_ambler@ca.ibm.com
author1-email-cc=

My developerWorks community

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Rate a product. Write a review.

Special offers