Live data from Hacker News

Ask HN: Working with large code base for the first time

news.ycombinator.com

31–40 of 90 posts

Re: Ask HN: Working with large code base for the first time

#31

I suggest you try JetBrains IDEs depending on your tech stack. They have got an incredible search capabilities. You can search for a word/function where it has been used across project, you can find and replace across the project, etc. It's amazing!

Wouldn't Vscode alone can do the trick? I have been using Vscode previously and could easily find implementions/definitions inside the project by searching.

Never used JB webstorm before, there will definitely be a learning curve with this new IDE. I am not sure the benefits weigh more than the time i have to get used to new IDE.

Re: Ask HN: Working with large code base for the first time

#32
Look for distinct patterns and code boundaries/modules.

Look at git commit (messages) and issues/PRs. Which parts of the codebase/process is involved in making which type of changes.

Any codebase, especially large ones, may not be consistent during to legacy and many reasons.

Use an IDE + grep/ag.

Re: Ask HN: Working with large code base for the first time

#33
post #29
post #26

If the project you are working on has enough time to burn, and the codebase has no (or near to) unit tests, add them. Find large utilities that are not coupled with a particular part of the application, and put them under heavy testing. Do not fix any failing test before having completed the test suite. If you have access to other developers that know the codebase, review the tests with them, and fix failing tests to…

How are you supposed to write tests for code if you don't understand what it does/is supposed to do?

You can create regression tests that prove that the code does what it does today - which helps you understand it, provides a readable description of what it does and protects against regression bugs in the future.

Here's a relevant trick I frequently use for this kind of work with Python: https://simonwillison.net/2020/Feb/11/cheating-at-unit-tests...

Re: Ask HN: Working with large code base for the first time

#34

1. Get confortable using “grep” [1], or better, “ripgrep” [2], which is quite faster than the former. They are both available in Linux, macOS, and Windows via WSL. 2. If the project uses a version control system (Git, Mercurial, Subversion, etc.) then take a look at the most recent additions, modifications, and/or deletions in the version control log (git-log, or whatever you want to call it). Sometimes, the most rel…

You can also use `git grep` if you're using git, and I'm sure analogues exist for the other VCSs.

Re: Ask HN: Working with large code base for the first time

#35

I like sourcetrail ( https://www.sourcetrail.com/ ). Sadly, in my latest position I have a Mac and I cannot get it to work on a Java project, as it complains that it cannot find a JRE at the $JAVA_HOME path that I specify (which works for all the other projects, including IntelliJ). Maybe between Christmas and New Year I might have some time to figure out what is wrong.

Sourcetrail is being discontinued. Are there any alternatives, even paid ones?

Re: Ask HN: Working with large code base for the first time

#36
post #34

1. Get confortable using “grep” [1], or better, “ripgrep” [2], which is quite faster than the former. They are both available in Linux, macOS, and Windows via WSL. 2. If the project uses a version control system (Git, Mercurial, Subversion, etc.) then take a look at the most recent additions, modifications, and/or deletions in the version control log (git-log, or whatever you want to call it). Sometimes, the most rel…

You can also use `git grep` if you're using git, and I'm sure analogues exist for the other VCSs.

+1 for git grep.

Re: Ask HN: Working with large code base for the first time

#37
- Before starting to dive into the code, take a look at it from the users point of view. Make sure you know what the code does by reading manuals and playing around with it.

- Don't try to learn domain knowledge from the code. I you need to get familiar with code of a JPEG decoder, learn how JPEG works first.

- Before reading code, make sure you can jump to definition and find references. The easiest and language agnostic way is to use ctags and grep.

- Start reading code from main() (or an API call in the case of a library) and then start to dig deeper. This way will get a feeling where the "important" code is"

Re: Ask HN: Working with large code base for the first time

#38

I suggest you try JetBrains IDEs depending on your tech stack. They have got an incredible search capabilities. You can search for a word/function where it has been used across project, you can find and replace across the project, etc. It's amazing!

Yea came to comments to say this, absolutely +1 for a JetBrains IDE, it takes care of almost everything.

Re: Ask HN: Working with large code base for the first time

#39
The architectural overview, either from the docs or from someone who can tell you, which gives you the 'lay of the land' and a rough idea of what does what. Like having a map.

Then, the custom idioms and weirdness that develops in every project, often it's a set of patterns that the team just 'acquires' - often it's in every file, every function. It's like learning 'words' specific to the language they have created for themselves.

Then get someone to explain the build systems, tooling etc..

And then, just of the sake of it - make sure to build it. Make a change and build it again. I think there's a weird leap in subconscious confidence that comes along with 'building it'. Like riding a wild horse for the first time, if you can do it for one second, you can do it for longer.

Once you have you head wrapped around the system, and the 'systematic things' (like idioms) and can navigate the tools ... then it a matter of breaking thing down into details. Which is where the work is of course.

But you need a 'map' and a 'cart' and your 'hammer' before you can start waltzing around Campus thinking about fixing things.

Re: Ask HN: Working with large code base for the first time

#40
post #31

I suggest you try JetBrains IDEs depending on your tech stack. They have got an incredible search capabilities. You can search for a word/function where it has been used across project, you can find and replace across the project, etc. It's amazing!

Wouldn't Vscode alone can do the trick? I have been using Vscode previously and could easily find implementions/definitions inside the project by searching. Never used JB webstorm before, there will definitely be a learning curve with this new IDE. I am not sure the benefits weigh more than the time i have to get used to new IDE.

VSCode is pretty barebones. You'll need to setup a language server and figure out how to search everywhere and also learn grep in the process if you don't know it already.

In Webstorm, you just press on Shift twice and a popup appears that allows you to search for everything you need. Since the IDE indexed all symbols in your project already, you'll be able to quickly find whatever you need.

Post reply on HN