Mastering the Codebase: How to Quickly Achieve Actionable Understanding
As a software developer, your codebase is your most important asset. Much like a craftsman knowing their tools inside and out, understanding your codebase at a deep level is essential. Not only does this allow you to navigate your environment confidentially, it greatly improves the likelihood of making accurate estimates of effort and complexity and supports you in delivering high-quality work. Conversely, a lack of familiarity with the codebase can lead to misjudged timelines, increased technical debt, a higher likelihood of introducing bugs and/or inefficiencies and even stagnation in your professional development and career.
This post will explore practical strategies to help you get to know your codebase better, regardless of whether you're starting a new job or looking to get ahead professionally in your current position.
Trace code execution
Following a piece of functionality through the codebase gives you a clear idea of the system's flow and operation. Are there lots of moving parts? Is everything handled in one place? Is the code new or old? By simply taking an action and unravelling its inner workings, you can quickly grasp the architecture and design of the code.
Start with the UI elements, if relevant, and then work through the code. This will allow you to compare the user flow with the code flow. Does it make sense? Are the two aligned? Compare the use of wording against variable and function names, are they conveying the same meaning?
Tip: Take note of the filenames and endpoints as you trace the execution, this creates a sort of stack trace for you to follow. Additionally, check to see if there is any documentation covering the aspect of the system you're investigating. If there isn't any, your stack trace could become the basis of a new piece of technical documentation.
Pair program
If you're starting a piece of work in a new area or hear about someone working on something you haven't explored yet but find interesting, ask if you can work on it together. Pair programming with someone more familiar with the area allows you to ask questions and get up to speed more quickly, bypassing much of the trial and error and upfront investigation necessary when working alone.
Tip: Before starting a pair programming session, ensure that goals of what you want to achieve from the session are clear. Agree on a specific problem to solve or a piece of the codebase to explore. Make sure to consider who performs the roles of "driver" and "navigator", as that might steer the learnings you can expect to gather.
Take advantage of Pull Requests
Pull requests (PRs) are a great way to stay updated on the changes being implemented in the system. They also offer an opportunity to ask questions and understand different areas of the codebase you may not have worked on yet. This not only shows that you’re engaged but also helps you learn why certain decisions were made. Engaging with pull requests helps you learn from others’ work and keep a pulse on the evolving state of the code. Remember that you don't need to leave a review (approve, decline, request changes etc.) to be able to ask questions. So you can peruse at your leisure without having to worry about overstepping your mark by reviewing unsolicited.
Tip: When reviewing pull requests, try to source them from as many different contributors as possible. This allows you to be exposed to a greater variety of ways of working and areas of the system.
Review and update documentation
Although often seen as more of a chore than a resource, reviewing, producing, and updating documentation can be a valuable method for improving your knowledge of the codebase. By documenting what you know, you reinforce your understanding and create an easily accessible explanation of the system's inner workings. This also creates a valuable resource for others which in turn elevates their perception of you.
Tip: As you review documentation check the change log/history if there is one. If you come across a section that hasn't been updated for a while, it could suggest its out of date.
Review the commit history
Understanding the evolution of the codebase and the rationale behind changes can provide context and insights into its current state. This can help you assess whether the foundation of the codebase is solid or problematic. With this knowledge, you can better estimate the feasibility of extending or maintaining the functionality.
In addition, when reviewing the commit history look for patterns in the types of changes being made. If you are consistently seeing bug fixes being applied to a particular area or module, it could suggest its no longer in active development and just in maintenance.
Tip: Use IDE plugins/addons such as Git Lens and Git Blame to see the commit history from within your preferred IDE. Additionally, try to reach out to the developers who made significant changes to gain insights into their thought processes and any challenges they encountered.
Start by writing tests
Writing unit tests, integration tests, or end-to-end tests forces you to understand the functionality and edge cases of the code. Reviewing existing tests can also provide valuable insights into code behaviour. If there are no automated tests, try using debugging tools to step through the code execution and learn how it operates.
Tip: When writing tests, start with edge cases and boundary conditions that are most likely to expose bugs. If you're stepping through the code instead, use breakpoints strategically to pause at key points in the code. This allows you to observe the flow and state of the application at critical points. If you encounter unexpected behaviour, take note of the variables and their values and consider raising a ticket to address the issue.
Play around
Try refactoring the code and observing what breaks! Does the whole system crash after a simple change, or is it a relatively painless experience? Knowing how easy or difficult it is to modify the code helps you predict how straightforward it will be to extend the functionality in the future.
Tip: If you encounter any issues or quirks you weren't expecting, raise them as tickets or query them with other members of the team. Taking the initiative allows you to present yourself as proactive.
Conclusion
Mastering your codebase is a crucial step in your journey as a developer. By consistently exploring, questioning, and experimenting within the code, you’ll not only become more confident and capable but also enhance your overall effectiveness. Whether you’re starting a new job or aiming to deepen your expertise in your current role, investing time in understanding the codebase will set you apart as a knowledgeable and proactive professional. By embracing these strategies you’ll find yourself better equipped to tackle challenges, make informed decisions, and more quickly contribute meaningfully.
Subscribe to my newsletter
Read articles from Jake Doran directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Jake Doran
Jake Doran
I help developers advance their tech careers and achieve their professional goals. With years of experience as a lead developer, I’ve guided both individuals and teams to reach their full potential. My passion lies in discovering and implementing methods that foster personal growth and technical expertise.