3 Steps to Reading New Code

Man writing some code

Approaching Code For The First Time

Whether you are approaching a code base for the first time or you are doing a code review for another developer, reading code may be like reading another “language”. In school, you get extensive instruction on how to write code, but rarely hear about how to approach a large code base for the first time. And then you enter the “real world” and learn that reading code is as essential a skill as writing.

A lot of our new engineers see codebases that are significantly larger than what they were presented with during their undergraduate work. This can certainly be overwhelming. Organizing it all in your head is often impossible in active codebases. We share three tips with our new engineers to make new code less intimidating.

Step 1: Look for the Documentation

When you are looking at a new codebase, the first place to look is a README file. This text file is typically located in the root folder of the codebase. There are a few things that this document should include to make the process easier for the reviewer:

  • What tools you need installed to compile this code
  • How you can run the code or the context it is used in
  • What the code is doing
  • What different blocks are doing

Step 2: Look for Entry Points

Next, you will want to identify your entry points and programs that will be most beneficial to your review. We suggest you open up your code, in an IDE or another editor that understands the declarations, can do syntax highlighting, and can do code folding, so you can squeeze the code down into just the headers and stay high level. If you’re in C, the entry point is usually going to be your main() function in a main.c file. If you’re using the Arduino framework, the setup() and loop() functions in the INO file are the entry points. Python will have the package name and the entry point will often be in a file with the same name. You will find either a main function or code will start executing from the top of the file. If you’re in C sharp, you’ll find a Main() or OnStartup() function in either an Application.cs or Program.cs file.

If you’re in C++ or C, start in your header files, just see what things are being called and avoid getting mired down in details of how exactly each function is implemented.

Step 3: Take a 10,000 foot view

Once you have found the entry point, identified the main function and/or the top files, now you can see where the code is going. Taking notes in the form of a sketch or diagram block helps this process, and can also help to identify how things relate to each other visually.

When you are looking at code for the first time because you’re going to start developing with others, taking a look through the recent history and active branches in the repo can help you understand the code as well. This will give you insight on where active work is happening, what others are watching for, what is changing. Looking through this history may even provide you hints on what parts of the code are most important.

What To Ignore As Long As You Can

While reviewing code, there may be a temptation to fix all the things you see. Perhaps because they are not the way you would do them or you could recommend a better way. This is where we encourage you to pause. Here are a few things you can ignore.

In short, anything that can be caught or fixed by automated processes are better reviewed by those processes. If you don’t have these in place, we have some articles discussing the how and why of automation, too!

Reading code is as important as knowing how to write it. While this is not a skill that is taught, it can absolutely be valuable to your team and clients. And if you have questions about an embedded project you’re working on, consider reaching out! At DojoFive, we have talented engineers on hand ready to help you with all aspects of your EmbedOps journey. We are always happy to help with interesting problems that need solving. You can reach out at any time on LinkedIn or through email!

Discover why Dojo Five EmbedOps is the embedded enterprise choice for build tool and test management.

Sign up to receive a free account to the EmbedOps platform and start building with confidence..

  • Connect a repo
  • Use Dev Containers with your Continuous Integration (CI) provider
  • Analyze memory usage
  • Integrate and visualize static analysis results
  • Perform Hardware-in-the-Loop (HIL) tests
  • Install the Command Line Interface for a developer-friendly experience

Subscribe to our Monthly Newsletter

Subscribe to our monthly newsletter for development insights delivered straight to your inbox.

Interested in learning more?

Best-in-class embedded firmware content, resources and best practices

Dev Containers

Dev Containers

Docker is well-known and is widely used in the software application realm. In recent years, it has made its way into many embedded software projects. In embedded development, it is mainly used for running builds and tests locally on the machine or on Continuous Integration/Continuous Deployment (CI/CD) platforms.  Check out our Using Docker for Embedded Development blog post to learn more about it. The Dockerfile can start off simple with a few required packages, and it quickly grows in size

Read More »
Hiring Isn't Enough: Building a More Resilient Firmware Team

Hiring Isn’t Enough: Building a More Resilient Firmware Team

Hiring experienced embedded firmware engineers has never been easy. Today, it’s even harder. Long hiring cycles, increasing technical complexity, and competition for experienced talent mean many engineering leaders are asking the same question: How do we build a stronger team when the people we need are so hard to find, and the products we ship can’t afford to fail? The answer usually isn’t recruiting alone. The most resilient teams invest in hiring, but they also create an environment where engineers

Read More »

Modern Embedded Firmware Development Practices in the Warehouse Automation Industry

In the fast-paced world of warehouse automation, the development of embedded firmware is a critical aspect that underpins the efficiency and functionality of automated systems. This blog explores the multifaceted realm of modern embedded firmware development, as well as the innovative testing practices that help identify and mitigate bugs early in the process, leading to cost savings and more robust systems. Modern Embedded Firmware Development in the Warehouse Automation Industry Embedded firmware development is the unsung hero of the warehouse

Read More »