Another strategy I like is picking parts of the codebase and trying to refactor them. You don't even need to commit anything if you're not supposed to go around changing things: just by spending some time moving things around, seeing what breaks and so on will give you a better understanding of the code and what it does.
Ask HN: What are the ways you go about getting comfortable with a new codebase?
21–30 of 69 posts
Re: Ask HN: What are the ways you go about getting comfortable with a new codebase?
#22Reading the codebase does surprisingly little for me, you essentially have to change it and see what happens.
Re: Ask HN: What are the ways you go about getting comfortable with a new codebase?
#231. 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 usually the oldest and most core part of how the program works, whereas more recent changes are business logic and feature addition.
But of these, the first yield the greatest initial understanding and allows me to change things with less fear.
Re: Ask HN: What are the ways you go about getting comfortable with a new codebase?
#24Re: Ask HN: What are the ways you go about getting comfortable with a new codebase?
#25Second - I learn how different components are wired together.
Re: Ask HN: What are the ways you go about getting comfortable with a new codebase?
#26I find the only way for me is to actually run the code locally, play around with it until I understand the data flow.
Re: Ask HN: What are the ways you go about getting comfortable with a new codebase?
#27Get 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 first week on the job.
Re: Ask HN: What are the ways you go about getting comfortable with a new codebase?
#28Also, attempting to draw a sequence diagram and fixing it as you go trains the brain to handle a mental model of a large process.
Re: Ask HN: What are the ways you go about getting comfortable with a new codebase?
#291. Fix a couple of bugs
2. Add a small feature
3. Refactor a small piece of it
Always start with few small things and keep increasing the complexity of the things you do. Working on a codebase is the best way to understand it.
Re: Ask HN: What are the ways you go about getting comfortable with a new codebase?
#30Also try to read tests, because they can show a lot about how the components are used and their properties.