|
|
|
|
|
by vikiomega9
1857 days ago
|
|
Most editors have code folding. I've noticed this helps when there are comments or it's easy to figure out the branching or what not. However, what you're asking for is a design style that's hard to implement I think without language tooling (for example identifying effectful methods). |
|
That is, given a "clean code like":
The tool would inline all the function calls. That is, for each of ProcessSth(), ValidateSthElse() and DoSth(), it would automatically perform the task of "copy the function body, paste it at the call site, and massage the caller to make it work". It's sometimes called the "inline function" refactoring - the inverse of "extract function"/"extract method" refactoring.I'd really, really want such a tool. Particularly one where the changes were transient - not modifying the source code, just overlaying it with a read-only replacement. Also interactive. My example session is:
- Take the "clean code" function that just calls a bunch of other functions. With one key combination, inline all these functions.
- In the read-only inlined overlay, mark some other function calls and inline them too.
- Rinse, repeat, until I can read the overlay top-to-bottom and understand what the code is actually doing.