4

Suppose you are tasked with understanding some software which is very complex, has a web of dependencies, and a loaded namespace. Let's say it's a controller of a compiler which is more or less undocumented.

Is there any codified notion, or name for a technique whereby one 'logs' the values of variables throughout execution, in order to learn about how the software works? Or maybe for only the scope of a given function? I imagine this would exist primarily as a debugging tool.

In my particular case, I am working with F#, so it would also be helpful if you had a specific reference.

Krpcannon
  • 111
  • 8
  • I usually try writing (or adding extra) unit tests, and then "scratch refactor". I would imagine a long list of variables and values will give you even more information overload. – doctorlove Jul 12 '17 at 11:04
  • My approach to this would vary greatly depending on how the code is structured. In well-factored F#, I probably would just read the code rather than what you're suggesting. – N_A Jul 12 '17 at 11:30
  • 2
    "printf debugging", "trace debugging", or "tracing" https://stackoverflow.com/questions/189562/what-is-the-proper-name-for-doing-debugging-by-adding-print-statements – TheQuickBrownFox Jul 12 '17 at 11:32
  • 2
    You might also try loading the code into FSI and running pieces of it interactively. FsCheck can be useful here to generate arbitrary instances of complex values that you can pass to a function to get it to run. – TheQuickBrownFox Jul 12 '17 at 11:39
  • Functional programming often assumes immutable state, while the debuggers work with the mutating values. So the usual debugging tools not always work. [This question](https://stackoverflow.com/q/31045246/) and its answers may help. – Be Brave Be Like Ukraine Jul 12 '17 at 16:51
  • 1
    I find that stepping through various test cases in the Visual Studio debugger can be very illuminating. – Brian Jul 12 '17 at 19:52

1 Answers1

0

What you are looking for is tooling that supports inspectors, tracers, watches (globals and locals) and context aware evaluators. Some editors may have plugins to enable this. As of (2017) LightTable-FSharp for the Light Table editor is available which shows an inline evaluator. Thank you.

Yemi Bedu
  • 190
  • 1
  • 9