Wednesday, December 19, 2007

UML for Coding

UML can be quite helpful in coding although it is not meant to substitute it. I don't think UML is suitable to be used in paralel/on the same level of coding, I prefer to use it as a support for coding. Here are some area that I find it most useful :

  • Reverse engineer code. If you work with other people's code or the code you wrote years ago, you'll most likely need to get a big picture of it, especially if it's written in the manner that is not intuitive to you. Extracting important classes, it's hierarchies and relations with other classes could help us in understanding those codes.
  • Get pass though blocking in coding. There are time when we feel lost int he middle of our coding and it feels like there's no where else you could go to. We got buried in the micro problems and details, loosing the big picture of what we are doing. This is the time where some high level review would help and some diagrams would be most-welcomed. After we can close the gap again between high-level view with the current problem we could start again with a clearer head and, hopefully, unblocked the dead-end we faced earlier.
  • Document some critical architecture decision. There are occasionally parts of programs that is hard to be made self-documenting no matter how hard we try to find names and structure that could reveal it. The code still won't reveal intentions clearly. This is the time for some external "patch" to the code in the form of words and diagrams.
As the support it is done in just-in-time manner. I fire up a UML tool when I need to do the above. Once things are clearer/unblocked I switch back to code and leave the diagrams alone until the time I find it neccessary to open it again. No synching necessary, I just sync it the next time I touch them again on the part that is relevant at that time.

UML could be helpful when done with the clear purpose i.e: not to replace code, and with the right amount of effort.

No comments: