Live data from Hacker News

Ask HN: How do you search large codebases before adding a feature or fixing bug?

news.ycombinator.com

31–40 of 87 posts

Re: Ask HN: How do you search large codebases before adding a feature or fixing bug?

#31
post #14

Earlier quoted context omitted.

Quoted post unavailable.

Maybe your comment is off topic? We are talking about searching. You are talking about good vs not good developers and understanding code. Searching != understanding.

Knowing how to search in a large code base is a large part of this and could be included in what ”good at reading code” means.

Re: Ask HN: How do you search large codebases before adding a feature or fixing bug?

#32

I work on code bases with millions of lines, so I wrote a tool called Septum to help me ( https://github.com/pyjarrett/septum/ ). This isn't to replace grep or ripgrep or silver searcher, those are all great tools you should have! Septum is neighborhood based (context-based) search, so you can find contiguous groups of lines which contain specific things, but exclude other things. It's also interactive so you can add…

Looks pretty awesome! Will definitely give a try!

Wish to hear why did you choose to use Ada?

Re: Ask HN: How do you search large codebases before adding a feature or fixing bug?

#33
post #5

IntelliJ / PyCharm / WebStorm ctrl-shift-F: search in the whole codebase, is what I use

IntelliJ is struggling noticeably navigating even my tiny 50 KLOC search engine project. I can't even imagine using its search function to get around MLOC-scale projects.

It really has no issue as long as you have enough RAM and disabled swap. I recently got a fairly decent gaming laptop that I'm supposed to develop on and the 16 GB RAM is constantly full and it's swapping all the time, browser keeps suspending my background tabs, really pain in the ass.

Re: Ask HN: How do you search large codebases before adding a feature or fixing bug?

#34
post #21

Earlier quoted context omitted.

Seen != Built. You don't always have to optimize for the right answer right away. Just asking someone who's worked with/on the codebase will often give you a jump start.

If someone worked on JIRA/Task we can find, otherwise, how do we even know about who has seen the codebase?

Presumably the code base didn't just have a single author (who is also no longer around). Git blame is amazing for not only tracking down who did what, but also seeing how the code base evolved.

Re: Ask HN: How do you search large codebases before adding a feature or fixing bug?

#35
I can recommend going beyond the source code and check the checkin comment or bugtracker entry of the code you intend to change (once you found it). If the code is strange or arbitrary there is often a reason, and knowing that will improve your understanding.

Re: Ask HN: How do you search large codebases before adding a feature or fixing bug?

#36

I work on code bases with millions of lines, so I wrote a tool called Septum to help me ( https://github.com/pyjarrett/septum/ ). This isn't to replace grep or ripgrep or silver searcher, those are all great tools you should have! Septum is neighborhood based (context-based) search, so you can find contiguous groups of lines which contain specific things, but exclude other things. It's also interactive so you can add…

This is amazing. So many times I've needed to do something similar to the demo, and I have to hack things around. I'll definitely be using this.

Re: Ask HN: How do you search large codebases before adding a feature or fixing bug?

#37
post #33

Earlier quoted context omitted.

IntelliJ is struggling noticeably navigating even my tiny 50 KLOC search engine project. I can't even imagine using its search function to get around MLOC-scale projects.

It really has no issue as long as you have enough RAM and disabled swap. I recently got a fairly decent gaming laptop that I'm supposed to develop on and the 16 GB RAM is constantly full and it's swapping all the time, browser keeps suspending my background tabs, really pain in the ass.

You really do not want to disable swap on Linux. The operating system does not handle out of memory situations well at all if you do.

At any rate, I've got 32 GB of ram and I'm operating off an NVMe-drive, I really don't see what the problem is.

Re: Ask HN: How do you search large codebases before adding a feature or fixing bug?

#38
0. Try to find what & why exactly is being built

1. Try to find out which framework, architecture, design patterns used - get hold of that

2. Library dependancy 3. Database structure

4. Pick up your favourite editor (be it vim or emacs or vs code or any) in which you have mastery

5. Search for various entry points like routes, or start activity or main function etc & try step thru code (with possible debug tools open)

Re: Ask HN: How do you search large codebases before adding a feature or fixing bug?

#39

Whenever working with a new codebase I always try to find the route definitions file first. Something that maps the api interface to the functions they call. I can then reason backwards from any service by clicking into whatever I’m interested in. After that I look for where config is defined and try to understand what’s unique about this envs setup.

I like this approach because it keeps the fact that code is supposed to DO SOMETHING front and center. There is so much temptation (and many excellent reasons) to organize code in various ways but I think the power of route-based thinking should not be underestimated. Obviously depends on what you're building, but for most web-apps, I would trade some code duplication for very clear "this-does-that" organization.

Re: Ask HN: How do you search large codebases before adding a feature or fixing bug?

#40

I almost always fall back on ag ( https://github.com/ggreer/the_silver_searcher ). Honourable mentions to cscope and ctags. They work for me since most of my $dayjob involves me mucking around with C++. All tools get invoked from within Vim. (Which _also_ works reasonably well in Windows Terminal).

I use cscope and tags. Making sure vim is set up to navigate by tag is a must too. But given those I always wondered what the other methods mentioned in this news item offer that cscope/tags doesn't

[deleted]
Post reply on HN