Live data from Hacker News

Ask HN: What are the ways you go about getting comfortable with a new codebase?

news.ycombinator.com

11–20 of 69 posts

Re: Ask HN: What are the ways you go about getting comfortable with a new codebase?

#12

Not using things like go to definition and any fancy tools, just manually forcing myself to work through files to understand how things fit together and using basic tools like grep

Very surprising! IIUC, you consider "Go To Definition"/"Go To References" and other "LSP assists" unhelpful (or worse) when familiarizing yourself with a new codebase. I personally find them indispensable. Could you say more to help me understand your position?

Re: Ask HN: What are the ways you go about getting comfortable with a new codebase?

#13

Run the code. This sounds so trivial but it's not always that easy. Once it get's running, I discuss with users of the code (be it customers or developers) and try to understand what they use it for and look for that same functionality in the code. Usually by this point I know where everything is and how to make changes if needed.

Even better than running code is running tests.

Re: Ask HN: What are the ways you go about getting comfortable with a new codebase?

#15

Not using things like go to definition and any fancy tools, just manually forcing myself to work through files to understand how things fit together and using basic tools like grep

I'd give the complete opposite advice.

I use "go to definition"/"find references" to go all around the code base and at the same time try to figure out how each files interact with each others.

Re: Ask HN: What are the ways you go about getting comfortable with a new codebase?

#16

Run it under debugger and go thru whole codebase a few times and you'll start getting proficient at it I've recently did it on huge, very very specific codebase and after 2-3 months I understood it (what to add where, not just what's happening where) relatively OK

With both lambdas and @ComeFrom instructions[1], it’s impossible. I’m impressed that a feat of modern programming (say, started with Java 8) makes the code difficult to understand. [1] https://en.wikipedia.org/wiki/COMEFROM

I have never heard of COMEFROM.

Re: Ask HN: What are the ways you go about getting comfortable with a new codebase?

#17
Besides all the great steps below, I like to browse the git repo to find the files that have been changed most recently and most often.

Projects, especially messy ones, often behave like lava flows where there is an active and ever expanding edge where changes are currently being made. Beneath this are layer upon layer of nearly impenetrable and often implicitly deprecated code from former developers.

This practice came from a time when I was brought in midway through a rewrite to get rid of unmaintainable code from some offshore contractors. I saw a repository where half the code lacked any organizing principles and had massive security issues. The second half was textbook (pedantic even) OOP, the kind taught in Java textbooks. It was beautifully executed except for using a few outdated tricks to do OOP in early versions of PHP (no longer needed in the version used for this project).

Because I didn't look at the dates, I assumed the neat OOP code was the result of the rewrite. I was wrong.

Re: Ask HN: What are the ways you go about getting comfortable with a new codebase?

#18
I often write out callstacks/dependency chains on paper. I find that makes it stick.

Try actually using the program as an end user would.

Read error messages, read code, make predictions about what the code does, find out if your predictions are true.

Re: Ask HN: What are the ways you go about getting comfortable with a new codebase?

#19
If there is one, I often like to look at the database. The stuff that is stored and the names of the tables should give you a good idea how the application works.

Sort of unrelated, but I've got a story about a project I was looking through that confused the hell out of me. It was a C# library that would allow you to render an element from a shockwave flash file (it was either .swf or .fla).

I spent ages digging through the code. The example worked really well, but I couldn't get it to work with one of my files.

Eventually I contacted the author and he told me the library used reflection to get the name of your variable and would look for that variable name in the flash document.

Re: Ask HN: What are the ways you go about getting comfortable with a new codebase?

#20
post #17

Besides all the great steps below, I like to browse the git repo to find the files that have been changed most recently and most often. Projects, especially messy ones, often behave like lava flows where there is an active and ever expanding edge where changes are currently being made. Beneath this are layer upon layer of nearly impenetrable and often implicitly deprecated code from former developers. This practice c…

[deleted]
Post reply on HN