Live data from Hacker News

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

news.ycombinator.com

61–69 of 69 posts

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

#62
post #43

As with most things depends on the code base, but if documentation in whatever form is available, I'd start there rather than just jumping into code. I'd start from the highest level abstraction of the code and work downwards until I reach a domain I'm either interested in or asked to work on and specialize on that vertical for a while (this can be anything from a few weeks to say 6 months). I then repeat the process…

This is very well written. 1-3 describes my experience of tinkering in Pharo except I haven't actually built anything with it.

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

#63

Two things - First - I learn how the data flows from the source to the end. That teaches me to navigate the codebase entirely. (User action to database, or source data to end data etc. Second - I learn how different components are wired together.

So indexing all the components and finding out all the interactions between them. This is exactly what class browsers do, they index all the classes and messages. The interactions could be described using an example/documentation.

This reminds me of Pharo which does all of the above, indexes classes, messages and has a rich documentation support.

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

#64
post #51

Earlier quoted context omitted.

Hey, I'd like to get a grasp of how to do what you're explaining, would you have any link or resource by chance? thanks!

This is my favourite explanation of flame graphs: https://rbspy.github.io/profiling-guide/using-flamegraphs.ht...

Good resource! Alas, the specifics really depend on the language.

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

#65
post #58
post #23

Three ways... 1. I go straight to the entry point, the main(), and then follow how the initial configuration, flow of data, sanitisation, and routing is done. 2. I look for bugs. Fixing bugs reveals the complexity as you need to look for side effects of the fixes when you don't yet know the system. Writing tests for those fixes also helps understand the system. 3. I look for the least changed part. I find these are u…

How do you think of #1 in the context of a web app? Each page is essentially a different entry point into the code. I guess the landing page or authentication page could be considered the equivalent, but I’m not sure those would hit your goals to understand flow of data, etc. ?

It makes even more sense for web apps. It will tell you how it came to be that a web page received the request, what context it has, how the cookie is resolved to an auth context, how to access any query args, what is available to support the page.

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

#66

Earlier quoted context omitted.

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?

If I start with these tools I get a feeling I understand how things fit together, but when I want to add something new I realize my understanding is pretty shallow. I force myself to manually open files where things are so I get an understanding of the conventions and principles in the project. By far my most valuable tool is grep (it’s super fast in vim) and I grep the code to see where certain functions and such ar…

Interesting. Thanks!

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

#67
post #58
post #23

Three ways... 1. I go straight to the entry point, the main(), and then follow how the initial configuration, flow of data, sanitisation, and routing is done. 2. I look for bugs. Fixing bugs reveals the complexity as you need to look for side effects of the fixes when you don't yet know the system. Writing tests for those fixes also helps understand the system. 3. I look for the least changed part. I find these are u…

How do you think of #1 in the context of a web app? Each page is essentially a different entry point into the code. I guess the landing page or authentication page could be considered the equivalent, but I’m not sure those would hit your goals to understand flow of data, etc. ?

Yup, I've stopped looking for the entry point in SPAs and apps. Often the navigation flow can be extremely convuluted.

Android introduced navigation graphs [1], which were meant to solve this problem. But what happened in reality were instead of arrows point to each screens, there would be multiple islands that were teleported in from random places.

[1] https://developer.android.com/guide/navigation/navigation-ge...

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

#68
post #23

Three ways... 1. I go straight to the entry point, the main(), and then follow how the initial configuration, flow of data, sanitisation, and routing is done. 2. I look for bugs. Fixing bugs reveals the complexity as you need to look for side effects of the fixes when you don't yet know the system. Writing tests for those fixes also helps understand the system. 3. I look for the least changed part. I find these are u…

#1 is my method too. I also take it as a sign learning the code base is going to be difficult if I have to ripgrep to find main because they couldn't put it in a cleanly named file like main.c =)
Post reply on HN