Ask HN: What are the ways you go about getting comfortable with a new codebase?
11–20 of 69 posts
Re: Ask HN: What are the ways you go about getting comfortable with a new codebase?
#12Not 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
Re: Ask HN: What are the ways you go about getting comfortable with a new codebase?
#13Run 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.
Re: Ask HN: What are the ways you go about getting comfortable with a new codebase?
#14Re: Ask HN: What are the ways you go about getting comfortable with a new codebase?
#15Not 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 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?
#16Run 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
Re: Ask HN: What are the ways you go about getting comfortable with a new codebase?
#17Projects, 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?
#18Try 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?
#19Sort 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?
#20Besides 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…