{ The Rithm Blog. }

Getting Acquainted With A Production Code Base June 18, 2019

At Rithm School, company projects have started. If you’re not familiar with company projects, it’s a three week portion of our curriculum where students work with instructors and outside companies on a real production code base. It can be a challenging time for both students and instructors as we’re all working together on problems and code that we’ve never seen before. But the challenge is definitely worth while. It’s a great tool for teaching good coding practices and how to work with a team. By the end of the three weeks, the students have a lot more confidence that they can contribute to a production code base.

working on code

Since it’s company project time, I wanted to write about some tips for working in a production code base. At first, the task can seem very daunting. You’re scanning through a huge amount of code and trying to understand lots of patterns that you had no part in creating. To make matters worse, if the code base is old enough, there might be sections of the code that no one who currently works at the company knows or understands. That may be a surprising statement, but it’s actually quite common when a project gets sufficiently large and old. Developers join teams and leave teams often. A section of code could have been written years ago by someone who has moved on to another project and the code hasn’t been touched by anyone since then. So with all of those challenges in mind, let’s dive right in, with the first tip.

Use the Application

This is a simple one but also very important. It’s hard to get a handle on the code base if you don’t know what features it has. So when you’re first getting caught up on the code, make sure you spend some time actually using the application. Try out all of the features. See what it does. Ask around for edge cases. What happens if a user isn’t signed in on this screen? Are there different types of users like admins, etc? If the code base is not a GUI, but rather an API, try making some requests. Read the documentation and understand all the parameters and things that you can do with the API. This should give you a fair amount of context for the next step.

Find The Main Components

Hopefully the project you’re working on isn’t one gigantic file. There will likely be some code that needs cleaning up, but there should also be some structure and organization to the code. So look through the code and try to find some main components. If the application is UI focused, try to understand where the main screens in the application are. If the application is an API, try to understand where each api end-point first receives the request and begins processing it. This goes hand in hand with understanding the features of the app. A good exercise is to choose a feature you’re fairly familiar with and then try to trace the flow of that feature through the code. It can be a big complicated feature or something rather small, but this process should help orient you within the code.

Tests!

Don’t forget about tests! (Assuming the code base your working on has tests). Tests help ensure that your code quality is high but they also function as living documentation about how the application should work. Read through the tests. Run the tests. Get a good understanding of the functionality that is being tested. If you find that the testing suite is lacking some coverage (in other words, there are pieces of the application that are not tested), try writing some tests for your first commit. By writing tests first, before you dive into new features, you’re learning more about how the application currently works and you’re helping to improve the quality of the code for future releases so it’s a win win.

Use Development Tools: Debugger, Stack Trace, Editor, Etc

When you’re learning a new code base, there are lots of pieces of the application that you may not understand. Let’s say you get a new task. For example, you could be working on something like “update the UI for a confirmation message when the user deletes some resource”. Perhaps, you’ve done all of the above tips but still have no idea where this code exists in the application. This is where your development tools can really help out. First, use your code editor to search the entire code base for the confirmation string that you see in the app. Maybe doing that alone leads you to the code that you need to understand to complete the task. If the search alone didn’t yield results, you could put a breakpoint where the string is being used then run the application and get the confirmation message to pop up. Assuming your debugger is triggered, now you can see very useful information like the stack trace! You could see all the functions that were called in order to get you to this point. That should shed some light on other pieces of the application that you need to understand to get this task done. If this is a web application, you could always use the html inspector in the developer tools as well to see how the confirmation message is getting created. Remember to use the tools you already know to help you understand the code better.

Summary

Learning a new code base can be a daunting task for any developer. The tips in this blog post are methods that I’ve relied on over the years to help me get a better understanding of code. Try using them in your daily development as well. I hope you find them useful!

Written by Tim Tim

Back to all posts

Get Started with Rithm School