Start from main() and start from the one click event(or any end-game action). Try to connect the two.
Ask HN: How do you familiarize yourself with a new codebase?
121–130 of 246 posts
Re: Ask HN: How do you familiarize yourself with a new codebase?
#122Re: Ask HN: How do you familiarize yourself with a new codebase?
#123Earlier quoted context omitted.
How is it counterproductive exactly? The setup of the debugger itself? Or trying to figure out how it works?
It depends on what you're working on. If you're working on, say, a huge Java codebase, then a debugger is practically essential because you've got a lot of code to navigate, and you probably want to see what flavour of objects are being passed around and how their state is being updated. On the other hand, if you're working on, ooh, a Nodejs codebase, you're probably looking at less code, with a debugger that's much…
Re: Ask HN: How do you familiarize yourself with a new codebase?
#124Re: Ask HN: How do you familiarize yourself with a new codebase?
#125Debugger! Surprised no one has mentioned it yet. I work in js and php, both of which I use the debugger a lot . Set a breakpoint, burn through the code. Chrome has some really nice features - you can tell it to skip over files (like jQuery) you can open the console and poke around, set variables to see what happens. Stepping though the code line by line for a few hours will soon show you the basics.
What debugger do you use for PHP? I've yet to find one I really like.
But I use xdebug and phpstorm. I find it better than netbeans. Search in netbeans is good, but the whole thing has a weird GUI and is slow.
Best bet is to try a bunch.
Re: Ask HN: How do you familiarize yourself with a new codebase?
#126I wrote some simple bash scripts around git which allow me to very quickly identify the most frequently-edited files, the most recently-edited files, the largest files, etc. https://github.com/gilesbowkett/rewind it's for assessing a project on day one, when you join, especially for "rescue mission" consulting. it's most useful for large projects. the idea is, you need to know as much as possible right away. so you r…
Thanks for sharing. I often get lost in large projects. Blindly jumping around is quite inefficient and frustrating. How hard do you think it is to write a tool to draw dependencies map for a specific language? May be there're built-in code analyzing tools in compilers for popular languages that I'm not aware of?
http://lonnie.io/gostd/dagvis/
If you write your project that even has no circular deps among files and all files are small (like me in https://github.com/h8liu/e8vm), you can draw the similar graph but at a much finer granularity, like this:
Re: Ask HN: How do you familiarize yourself with a new codebase?
#127A post from last year, "Strategies to quickly become productive in an unfamiliar codebase": https://news.ycombinator.com/item?id=8263402 My comment from that thread: I do the deep-dive. I start with a relatively high level interface point, such as an important function in a public API. Such functions and methods tend to accomplish easily understandable things. And by "important" I mean something that is fundamental t…
Re: Ask HN: How do you familiarize yourself with a new codebase?
#128I'll start reading the files using any of the strategies mentioned here and looking for things I can cleanup. Formatting, Simple Refactors, Normalizing Names.
These are all things that are comparatively easy to do and safe but force you to reason about the code you are reading. Asking yourself what you can refactor or fix the naming for is a deent forcing function for actually understanding the code.
Re: Ask HN: How do you familiarize yourself with a new codebase?
#1291. Just make sure I can build project;
2. Play around with services/application (just run, send some requests, get response);
3. Pick up simplest case (for example, some request/response);
4. Find breakpoints (for debugging) somewhere connected with this simplest case (for example, which stopped somewhere when I send request) and setup them in debugger. Usually, I find place where to put breakpoint by just searching keyword associated with my request;
5. Play around with these breakpoints while performing simplest case (for example, sending request) and try to find out call graph;
6. Try to change code and see what happens;
After I do this stuff several days/weeks, I become more and more familiar with the project.
Re: Ask HN: How do you familiarize yourself with a new codebase?
#130As you start to add to a project the IDE can also prove valuable in discovering how everything fits together, since it will provide smart and helpful completions with docstrings, method signatures, types etc. This can really help you start writing new code a lot faster.
Also, an IDE will usually also have a decent UI for running the code with a debugger attached, which can be incredibly useful for understanding the changing state of a running program.