3 ms·
As a decidedly non-novice programmer, one thing I do when mapping out unfamiliar code architectures, which I haven't seen anyone else doing, is to generate larg
by nyanpasu64 4y ago
As a decidedly non-novice programmer, one thing I do when mapping out unfamiliar code architectures, which I haven't seen anyone else doing, is to generate large-scale code maps by "inlining" function call bodies into a large Google Doc, creating a deeply nested tree where indentation maps to control flow and stack depth, and vertical position maps to execution order (excluding loops). Then I often trace data flow for important variables, by giving the variable one foreground or background color, then giving all future usages of the same value (or pointers to it) the same color. Unfortunately preparing this type of document by hand is quite time-consuming. https://marketplace.visualstudio.com/items?itemName=wcrichton.flowistry https://marketplace.visualstudio.com/items?itemName=wcrichto... seems to be a preliminary attempt at tracing data flow within a function, but doesn't seem to currently handle cross-function data flow (or generate an inlined tree suitable for visualizing caller-callee and sibling-call control flow).
- kaba0 4y agoSourcetrail can give you similar (plus interactive!) visualizations automatically.
- sidpatil 4y agoWhat you're describing is generally known as interprocedural dataflow analysis. (Interprocedural because it handles dataflow across function calls.) You can look into building a tool that can extract all or at least part of that dataflow graph for you by analyzing the AST. There are different approaches to this, some being more imperative (write a program to implement a chaotic iteration algorithm which builds the graph) and some being more declarative (extract facts about the code and feed them to a Datalog engine alongside a DL program describing the relations required to build the graph, or utilize something like CodeQL which already has the functionality available.)