Why UML won't save your project
Modelling a badly thought-out project just doesn't help...
The project's been wobbling along for 18 months. A bottle of champagne just went to the tester who logged the one millionth bug in TestDirector (and everybody cheered), the lead programmer looks like a raccoon that's discovered a departed junkie's heroin stash buried beneath a tree, half the programmers have quit, and the customer believes everything's fine... Although it does strike him as odd that all he's seen so far are static screenshots and Gantt charts with every single task stuck at "90 per cent". The project's in trouble.
So what does the team do? They've read the IBM/Rational marketing blurb, so they firmly believe that they can "do UML" on their project and that this'll have a miraculous effect on the bug-riddled codebase. It's this vague desire to start doing the right thing in order to save the project that can sink a team even further into the swamp.
When a project is in trouble because of a lack of initial analysis/design thought, the worst thing to do is to stop everything and start modelling the whole sorry mess in a CASE tool. It seems reasonable to want to create a clear picture of where you're at: a level playing field from which to start fixing the design. But muddy water poured into a crystal flute is still muddy water. Now you've got the same dysfunctional mudball in two places - the code and the UML model. Great.
It's also tempting to automatically reverse-engineer the code into class diagrams using a modelling tool. This might have an unseen benefit in that it'll shock whoever sees the resultant diagrams into realising just how bad the problem has gotten, but the diagrams themselves will be as scary as the code they're modelled on, a jumble of criss-crossed lines and teeny-tiny overlapping boxes that could rival anything in the Tate Modern.
I'm a great fan of UML, but like any tool or language it can be misused horribly – and usually is, because people start to use it for the wrong reasons, e.g. to do the thinking for them or make their team cleverer.
The right time for drawing diagrams is near the start of the project (or new feature, or weekly/monthly development sprint) when you do a little collaborative modelling with the whole team involved and figure out how it'll all fit together.
So it's worth emphasising: the solution is not to start modelling the existing illogical codebase in UML. However, do map out your ideal new improved design, unfettered by the constraints and design dead-ends of the current system. But the first thing to do (assuming you can't just scrap it all and start over) is cover the existing code with unit tests so you can begin refactoring your way to the new design.
But even before that, you must know what it is you're actually designing. Start with the basic questions: Who's the project for? What problems is it addressing? If you're feeling especially virtuous today, map out some use cases and try to drive the new design from them. Don't be afraid to come up with something very different from what you currently have.
UML used at the right time and in the right way can work wonders - it'll set the foundations for a successful, well factored project. But, to adapt Frederick Brooks' famous law about the perils of adding resources to a late project, stopping to map out the bad design on a late project will just make the project later.
Matt Stephens co-authored Use Case Driven Object Modeling with UML: Theory and Practice and Agile Development with the ICONIX Process.
Sponsored: Network DDoS protection