Saturday, June 19, 2004

Quick, Easy, Free UML Diagrams of Java Classes

I sure do love it here in the Java open-source community!

I read in Martin Fowler's blog that there's a cool open-source tool, called UMLGraph, he's been playing with for rendering UML class diagrams. If Fowler says it's worth checking out, then that's good enough for me. What the heck? I'll give it an hour.

So, I installed the tool itself (a JavaDoc Doclet -- just one jar), and I installed the free executable from AT&T Labs that actually does the rendering. I added a JavaDoc command to my Ant build script, and I added a call to the AT&T tool. Walla! Pretty UML diagrams to go with my program! It couldn’t be any simpler.

Not that I'll ever wait until the end of a project and generate reams of UML documentation to sit on a shelf -- what this will allow me to do is start to write new Java code, without any meat on the bones yet, and immediately get diagrams as I go to show off at design reviews and whatnot. Don’t like the way the design looks? I'll just take advantage of the Eclipse refactoring tools, and then re-render the diagrams. Is that slick, or what? No need to pay for a Rational Rose license, nor go though contortions to install it. No need to learn how to use the Rose UI. And, best yet, no need to "transcribble" (transcribe with possible errors) the design into code -- it's already code.

Note that I've only played with UMLGraph's class diagrams thus far. There's also a way to draw sequence diagrams, but it doesn’t work off of the Java source. You have to use something called the PIC language, so that's not as slick, but I'm not complaining. Being able to render class diagrams quickly and easily (and cheaply) is a tremendous boon. I couldn't wait to spread the word.

Oh, and back to why I love the Java open-source community: Fowler's blog entry wasn't even a day old when the UMLGraph people changed the front page of their site to reference the suggestions for improvement that Fowler made. I wouldn't be surprised if the team has acted on them already.

No comments: