Live data from Hacker News

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

news.ycombinator.com

31–40 of 69 posts

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

#31
I scan everything that is closely or remotely related to the code base: the code, commit logs, diagrams, bug reports, change requests, user manuals, tests, technical logs, databases, other storage, cloud infra, ...

Usually at least one of them stands out, so I at least read this through (usually diagonally).

I might also pick different things based on my goals.

Once I think I have a grasp of the high level aspects, I start pairing or validate with tiny feedback loops.

Update: I also create my own (naive) helicopter view diagram of the context and validate it with people on different levels.

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

#32

Try to profile the code and see where it's spending time. Get a good flame graph up, and you'll have a really solid visual representation of what's going on. Bonus: on almost any project, nobody has done a profiling pass in at least a few months, so you'll probably discover some extremely easy performance improvements and you'll look like a goddamn hero when you speed up e.g. the test suite by a factor of 3 in your f…

Definitely a good advice. Profiling is something I haven't looked into and should be after debugging.

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

#34
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…

1st is exactly what I do while reminding myself that I don't need to understand everything. Somehow for me it's easy to think like that in OO code and not FP.

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

#35
Just mapping the whole codebase without a specific goal in mind seems counterproductive to me.

Instead, I get myself a couple specific tiny bugfixes/features to do first. Just finding out where those are, one by one, tells you a lot and may not be as simple as it sounds.

I was once hired to help with polishing a code base for imminent shipping. I fixed one bug. The fix was one line, but not trivial at all. Took me a whole week of reading code. The customer was extatic. There were like 12-15 years worth of layers of code to read.

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

#36
post #10

Fixing bugs. Someone can explain a code path, what it should do, what the bug is and with that you can get familiar with a path through the application.

This! Ask around about the big things everyone would like to change and where the scary code is that nobody wants to touch, and with those things in mind, fix some bugs. The initial questions will tell you what to avoid initially. Longer term, if you can fix them you'll look like a rock star.

Fixing bugs has worked out although I had to pull my hair.

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

#37
If the codebase is ginormous and hard to decipher then you could use the magic source control to go back in time to an early point in the codebase. It’s probably going to be easier to understand a codebase that is 3 months old vs 6 years old, so you could go and check out that version, understand it and then jump forward a few years. This also gives you the benefit of understanding the evolution of the code and understanding why it is not just what it is.

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

#38

Ideally you have someone experienced in the codebase who can give a lay of the land. I suggest: 1. Find a senior dev, ask then for exisiting pointers to good documentation to self learn. 2. give that a go, make note of all the questions you have 3. then have a session with that dev for platform walk through. Take lots of notes and ask your questions. 4. offer to update docs where you found errata or missing steps or…

This is exactly what I would do ideally except I couldn't. I can understand that working in startups you would overlook alot of theory and due to hectic nature low quality calls(code/architecture explanation) are not appreciated.

And that's why the first thing I ask during a technical interview is "Do you have internal documentation?".

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

#40

Try to profile the code and see where it's spending time. Get a good flame graph up, and you'll have a really solid visual representation of what's going on. Bonus: on almost any project, nobody has done a profiling pass in at least a few months, so you'll probably discover some extremely easy performance improvements and you'll look like a goddamn hero when you speed up e.g. the test suite by a factor of 3 in your f…

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!
Post reply on HN