Ask HN: Better code readability/reviewability

  • You're looking for a refactoring tool that can perform 'inline method' refactorings (the reverse of 'extract method', which turns whatever you selected into a function call)

    And yes, the idea is language-agnostic, but tools doing it aren't, and, generally, tools are easier to write for less dynamic languages.

    One way to deal with code you do not understand is to print out the various functions, sit down with them away from your computer, but with a few differently colored pens or pencils, and start making notes.

    It also can help if you can single-step through the code with a debugger, even if it's just to be able to write down a few (inputs, return value) pairs.

  • > I'm having trouble reading the code and being able to understand what exactly is happening.

    [...]

    > Alternate question: How the heck do you deal with situations like this?

    Rewrite the fragment so it's easier to understand. Because...

    > [E]ach of [several nested] functions are present in different files (which are in different directories). (I'm sure there's legitimate reason for modularizing code to such an extent).

    ...you probably have code that works with several different abstraction levels at the same time.

    And no, there may be no legitimate reason to keep it that much split up (as you call, "modular"). It may be just an abuse of overestimated DRY principle.

  • Code connect maybe, best bet is to single step through the whole thing a few times.