How to visualize code?
- by gablin
I've mostly only had to read my own code. As such, I've had no need to visualize the code as I already know how each and every class and module communicate with one another.
But the few times I've had to read someone else's code - let us now assume we are talking about at least one larger module which contains several internal classes - I've almost always found myself wishing "This would have been so much easier to understand if I could just visualize it!"
So what are the common methods or tools for enabling this? Which do you use, and why do you prefer them over the others? I've heard stuff like UML, module and class diagrams, but I imagine there are more. Furthermore, any of these is most likely better than anything I can devise on my own.
EDIT: For those who answer with "Use pen and paper and just draw it": This isn't very helpful unless you explain this further. What exactly am I supposed to draw? A box for each class? Should I include the public methods? What about its fields? How should I draw connections that explain how one class uses another? What about modules? What if the language isn't object-oriented but functional or logical, or even just imperative (C, for instance)? What about global variables and functions? Is there an already-standardized way of drawing this, or do I need to think up of a method of my own? You get the drift.