Hacker News new | ask | show | jobs
Ask HN: understanding complex code: is pen and paper my only option?
2 points by c3c 1152 days ago
I'm learning a complex codebase. Jumping thru definitions is exhausting <:( Are there any tools that generate usable diagrams? My codebase is Java but the question is general. Thanks!
2 comments

This depends entirely on the language. An AST[0] can be derived from most any language, but how it is generated depends on the language's syntax.

An IDE (or IDE plugin) specific to the language is probably your best bet. Java has a huge ecosystem, so I would be surprised if nothing exists.

Also I would warn you that the results may not give you what you want. If the code was written such that it is impossible to tell what is going on without dropping into the details of every call, it is possible a diagram or graphic will not be as pretty as you expect.

Another option I've found useful when navigating is adding my own temporary comments in the code as signposts.

I would not discount pen & paper as a valid tool. Nothing wrong at all with jotting things down in a way that helps you understand someone else's code.

Lastly I would recommend remembering your struggles as you write code of your own, that someone else (or yourself) will have to slog through in the future.

[0] https://en.wikipedia.org/wiki/Abstract_syntax_tree

Thank you. I would have thought some kind of code-aware design studio would be available, but can't find anything. So much legacy code has been written over the years and no help digging into it...
Some IDE's provide a decent graphical project overview. If not themselves, look for an extension.