What Is Code Ownership?
TL;DR - Code ownership is a model used by teams of all sizes to ensure code quality is high, critical areas of code are protected, and power many automations; including requesting pull request reviewers from code owners. There are two fundamental approaches to code ownership; individual (1 or more engineers per file / directory) and collective (team(s) per file / directory).
Code ownership is a model in which a developer or team of developers are responsible for a specific piece of code within a software project. These developers are called code owners. The exact responsibilities of a code owner largely depend on the code ownership model (strong, weak, or collective), but overall, code owners are responsible for maintaining the code’s structure and quality.
Code ownership helps organize and manage responsibilities, making sure that everyone in the team has a clear understanding of who is responsible for maintaining the quality and functionality of a particular piece of code. This could be anything: from testing, maintenance of the source code, or fixing bugs. Put simply, a developer or team of developers (code owners) that are responsible for a piece of code (in a codebase) must make sure that the code is well-designed, bug-free, and of high-quality.
Code owners are also expected to respond to bug reports, requests for new features, and approving pull-requests. They are also usually the people to reach out to for any questions or issues related to the code they own. This process is known as code review.
The code ownership models are implemented widely because it helps with collaboration (if used efficiently). Please note: when we say 'code owner' below we are referring to all models; including individual and collective (teams).
Benefits of code ownership
Some benefits of implementing code ownership models are:
- Better accountability: It is easier to identify and address issues to the right person, since there is a clear code owner. Knowing who the code owner is helps avoid the cat-and-mouse chase that frequently happens within teams. People needing help can go directly to the code owner instead of wasting time asking other team members who the code owner is.
- More efficient: Code owners are more likely to be familiar with the code they are managing, thus work more efficiently and make changes quicker than someone who is not familiar with the code. This leads to reductions in pull request cycle time, meaning code makes it to production faster.
- Higher-quality: Code owners are more likely to deliver high-quality code, as developers who are tasked with managing the code are more likely to take pride in the work they do. Additionally, code owners reviewing pull requests leads to increased code quality as proven in an independent study by Microsoft. (A summary here from the CEO of DX)
- Better collaboration: Code ownership encourages collaboration between developers and team members. It also helps developers immediately reach out to the right team member in order to collaborate, especially useful in remote and async work environments.
Code ownership is important and critical in helping organize development teams, especially larger ones, as it helps teams facilitate collaboration and distribute responsibilities.
However, code ownership can have drawbacks. For example, not using the code ownership model that fits your team’s needs may negatively impact their efficiency instead of helping improve it.
Strong code ownership drawbacks
For example, in a strong code ownership model vs collective code ownership, the code owner may be less inclined to seek help or assistance from other members of the team, which results in lack of collaboration and may negatively impact the quality of the code.
Here are some other negative effects of the strong code ownership model:
- Poor code quality: The code owner is the only one maintaining the code; resulting in the code losing its quality over time if they are busy with other tasks or not available at the moment.
- Inefficiency: It can be time consuming to go over the code owner every time a small change is to be made. In other words, it is difficult to make changes to a code base you do not own.
- Stunts growth: A code owner may be resistant to change and new ideas other members of the team bring to the code they own. Thus, stunting growth and evolution of the code base, and the code owner. Developers should be open to learning from their peers.
Although code ownership has its drawbacks, it is great in helping with organization and team efficiency. It is important to research code ownership in order to know what model best fits your team.