Ask HN: How do you discover features in unknown code bases?
1–10 of 26 posts
I'm realizing that one of the reasons why I don't do a lot of additional hobby programming is because I'm missing a fundamental skillset that I never developed (in a reliable way) over the years. I think I don't know how to discover features that I'm interested in, in code bases that I'm unfamiliar with.
Example: In Chromium I want to find the algorithm that is building the DOM. I'm not sure if that is even part of the code base (https://github.com/chromium/chromium)
How would you personally approach this problem?
Re: Ask HN: How do you discover features in unknown code bases?
#2Read the tests.
Re: Ask HN: How do you discover features in unknown code bases?
#3sourcetrail is still modern. It hasn't fully bitorotted.
Re: Ask HN: How do you discover features in unknown code bases?
#4Clone the repository, open it and let my IDE build an index of the codebase, then use ctrl-p and/or ”grep -r keyword .”
Re: Ask HN: How do you discover features in unknown code bases?
#5Read the tests.
First you may need to find the appropriate tests, which is essentially the same problem OP describes.
Re: Ask HN: How do you discover features in unknown code bases?
#6Reading and drawing out the structure as you read. Boxes with arrows or whatever.
A good source structure tool will save some time but you’re not getting away without doing your own reading anyway.
Re: Ask HN: How do you discover features in unknown code bases?
#7It's hard. Normally I start with a word that I know is fairly unique to the domain I'm looking for (in your case maybe "cssselector"). And what you are looking for is in the Blink third party folder.
Re: Ask HN: How do you discover features in unknown code bases?
#8You use code search. For chromium it's hosted at https://source.chromium.org/chromium.
You can use filters to narrow down the results to the right languages and paths.
Re: Ask HN: How do you discover features in unknown code bases?
#9ripgrep
But to not leave a one word answer, start searching for a feature you know about and look around from where you find it. It might help to add a super small feature yourself - when it finally works, you’ll have some idea of how the code is structured and will be able to infer where other features would live if they were there. (That might take a bit more than one addition ;))
In chromium’s case, what you’re trying to do is more like reverse engineering… I’d start with a debugger.
Re: Ask HN: How do you discover features in unknown code bases?
#10Usually some kind of string search works. If it's frontend then search a string that's on the feature. If it's backend search a string for table name, http error messages, anything like that.