development

Don’t panic: Tips for learning a new code base

If you’ve ever joined a new company, or even switched teams at one, you’ve probably found yourself faced with an unfamiliar codebase. That was the case for me at Jana just a few months ago. I was coming from a code base that I had worked in for over 2 years, needless to say it was very familiar to me. It had been a long time since I was lost in a codebase, but that’s how I felt my first few days here at Jana. Here’s a few tips about what to do when you feel lost and how to approach an unfamiliar codebase.

Lower your expectations

Take a step back and say to yourself “I’m going to be wrong, a lot”. You’ll be wrong about how long you think a task will take, you’ll be wrong about how you think a feature works, the way you implement your first feature may even be wrong. It’s okay to be wrong. If you go in expecting things to take longer and expecting yourself to make mistakes it will make the transition much easier. If you’re like me, being wrong so much may make you feel bad and even feel like your performance isn’t up to par. I like to express that during my first few one on ones with my manager and get their perspective on my performance as early as possible. You’ll probably find that you are ramping up well and you’ve learned a ton! No engineer I have ever met looks back on code they wrote in the past and doesn’t have things they’d change. The most important thing is to ship code, the sooner you can start shipping the sooner you’ll start feeling comfortable.

Get an overview

It doesn’t have to be much, but sit down with someone and get a high level overview of how the code base is structured. You’ll want to know how the code is organized, what design patterns are used and expected, and what things are unique to the codebase. When I’m part of these overviews I try and provide, or get, an entry point. My goal is to leave the overview with a place to start when I open the codebase to work on it for the first time. It can be helpful to know what you’ll be working on when going into the overview, hopefully the person providing it will be able to point you in the right direction. Try to resist digging too deeply into every part of the codebase, and focus on a high level to start.

Learn by doing

I know this isn’t the case for everyone, but a majority of the people I have worked with have preferred to be given a task and dive right into the code. I once tried to spend a day “learning” the codebase, I had no specific task, I was just getting familiar with the code. It didn’t take long for me to get frustrated and asked my Product Manager for a task to work on, which they happily supplied. Having a task lets you focus on specific parts of the code, it gives you a starting point.

Write it down

“I’m not writing it down to remember later, I’m writing it down to remember it now”. If you’re a fan of Field Notes that line will be familiar to you, it’s their tag-line. When I’m faced with a large task in any codebase, not just unfamiliar ones, one of the first things I do is take out a notebook. As I trace through the code I write every step down. Not only does this give me an easy reference for traversing, it also helps me internalized what’s happening. The last time I did this I even found a few optimizations that could be made. If you really hate paper, you can do this exercise in your favorite text editor and achieve the same benefits.

Review pull request

Jana made me love code reviews. They’re good for a lot of reasons, one of which is getting familiar with code bases. Early on at Jana I rarely merged pull request for people, however, I did look at almost all the ones my team created. It helped paint a picture of how the team writes code and what practices we used. It also exposed me to more of the code than I would have encountered on my own. Code reviews aren’t just for the requester. You’ll find tricks you never knew about, and help your teammate get their code shipped.

 

Next time you need to learn a new codebase try out some of these tips, I know all of them have helped me in the past. Did I miss your favorite tip? Drop a comment and let me know! Hopefully they can help you too.

 

Discussion

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s