Code Ownership
What is Code Ownership
Code Ownership refers to the concept of having ownership and responsibility over the quality and maintainability of code.
In Software Development, everyone working on a project is responsible for the overall quality and maintainability of the codebase. However, as projects grow in scale and the number of contributors increases, this responsibility can become difficult to manage.
With an increasing number of changes being made to the codebase, it becomes harder for everyone to stay up-to-date on the code and understand the reasoning behind each change. As individual knowledge of the codebase becomes more fragmented, team members may start to feel disconnected from the project as they increasingly focus only on their own areas of work, leading to a sense of apathy towards the project as a whole.
Code Ownership helps address the fragmentation of domain knowledge in a project by assigning the responsibility for portions of that project's codebase to teams of developers, referred to as Code Owners.
This ownership can range from overseeing an entire domain (e.g. testing) to being responsible for a single module (e.g. a specific feature). By having designated owners for each part of the codebase, everyone can better understand the project as a whole and maintain its quality and maintainability in a more manageable way.
Code Ownership and its impact on our customers' experience (Customer Centricity)
Code Ownership plays a significant role in shaping the customer experience and building their confidence in our products, features, and ultimately, our company. A well-designed product that is prone to technical failures can quickly drive customers away.
By assigning specific parts of the codebase to Code Owners, the development team can ensure that each area of the code is maintained by someone with the required expertise and knowledge. This leads to a more organized and streamlined process for reviewing code changes and fixing bugs, resulting in code that is less prone to technical issues and more reliable.
This focus on code maintenance and education not only enhances the customer experience but also helps build customer trust in the code we ship, which in turn drives more customers to our business and strengthens the loyalty of our existing customers through a consistent, reliable experience with our products and features.
In conclusion, Code Ownership helps create a more stable and trustworthy software product for the customer, fostering confidence in our products and our company.
What is a Code Owner
A Code Owner is a Software Developer on a project who is responsible for ensuring the quality and maintainability of the code they are assigned to own.
Code Owners are typically assigned ownership of specific parts of the project's codebase based on their domain expertise and knowledge. For example, a developer or team of developers who have implemented a module may be assigned code ownership for all related code.
By assigning Code Ownership, each member of the project has a specific area of responsibility and focus. This allows individuals to concentrate on maintaining their assigned code and educating others on it, ultimately contributing to the overall success of the project.
While Code Ownership is usually assigned to experienced and knowledgeable Software Developers, less experienced or knowledgeable developers can also volunteer to take on Code Ownership, alongside other Code Owners, to gain experience in a specific domain.
In this case, their reviews and approvals would initially be optional rather than required, allowing them to gain the necessary knowledge and experience without adding pressure or creating issues for the approval process.
Adding optional approvals through scripts into our Code Owners file is still not implement, but is on the Native Platform's TODO list, and will be added soon. How the Code Owners file works is covered in the below [Code Owners File](#The-Code Owners-file) section.
In the meantime, optional Code Owners can be added manually, however note that the scripts will overwrite any changes made to the file, so any manual edits will need to be reapplied.
A Code Owners job
In simple terms, a Code Owner's job is to maintain the quality of the code they are assigned to own, whether changes are made by them or others.
This includes ensuring the code remains maintainable, by keeping it up-to-date, free of bugs, documented and understandable to others who may need to work on it in the future.
Responsibilities of a Code Owner
- Enforcing and educating others on industry standards and best practices,
- Reviewing code changes,
- Addressing and helping with issues arising from code changes,
- Acting as domain experts and educating others.
Enforcing and educating others on industry standards and best practices
As a Code Owner, you are responsible for ensuring that the code you are assigned to own is of high quality and maintainable.
To achieve this, it is essential to follow the project's own rules and guidelines, and it is equally important to stay informed of industry standards and best practices in Software Engineering and any related domains.
By adhering to these rules, guideslines, standards and best practices, we can set expectations for what is considered "good" when contributing changes to the project, promoting consistency and improvement across the codebase.
Project rules and guidelines
As a Code Owner, it is your responsibility to be familiar with and follow the project's own rules and guidelines. These rules and guidelines can be found in the project's documentation, including a dedicated documentation site, documentation files within the project's repository, or even within the code's source files as code comments.
It is imperative for Code Owners to follow and enforce the project rules and guidelines to ensure the quality and maintainability of the code they are responsible for. Keeping these rules and guidelines up to date is important, as it ensures they reflect the latest industry standards and best practices.
Standards
As a Code Owner, you play a crucial role in ensuring the quality and maintainability of the code you are responsible for. One of the ways you can do this is by following industry standards and best practices in software engineering and any relevant industry domains.
Industry standards are widely accepted and recognized sets of guidelines that define what is considered normal and typical in a particular industry. For example, the Hyper Text Markup Language (HTML) specification. These standards act as rules, and non-compliance can result in technological issues or compatibility problems.
It's essential for Code Owners to be familiar with the industry standards relevant to their Code Ownership and to ensure that they are implemented and followed by themselves and others working on the code. If the current standards are not being followed, it's your responsibility as a Code Owner to implement them. If others are not following the standards, you should raise the issue with the code contributors and enforce the standards during code reviews.
Best practices
In addition to industry standards, Code Owners also need to be familiar with current and emerging best practices in their domain. Best practices are recommendations based on the experience of other professionals and experts and provide guidance on the "best" way to do something. Unlike standards, best practices are not rules and may need to be adapted to fit specific scenarios.
If there are no current best practices for your Code Ownership domain, it's your responsibility as a Code Owner to set the guidelines. To do this effectively, you should seek the feedback and wisdom of others in your project, and engage in collaboration with your peers.
If the owned code does not follow current best practices, it's your responsibility to implement them or to ensure that others contributing changes follow them. You can do this by enforcing best practices during code reviews and providing education and guidance to others working on the code.
It's essential to keep up-to-date with the latest developments in your domain, so that your best practices are always current. Constantly staying informed about the latest best practices will help you provide the best guidance and support to others working on the code you own.
For a list of helpful resources to stay up to date with things related to this project, visit our Learning resources page.
Reviewing code changes
As a Code Owner, you are the primary reviewer for any code changes made to the code you own, and are expected to act as a domain expert for others who seek guidance on industry standards and best practices within your area of code ownership.
Your role in reviewing code changes through a Merge Request is not only to ensure code quality, but also to facilitate knowledge exchange between you and the code contributor. The code review process helps you identify and address potential issues early, before they affect the wider project codebase and ultimately, the business and its customers.
It is your responsibility to raise any potential improvements or issues with the code contributor and to enforce industry standards and project guidelines. If necessary, you should also make the necessary improvements yourself. Your extensive knowledge and expertise in your Code Ownership domain make you uniquely equipped to identify and address these issues.
Remember, these responsibilities apply to everyone working on the project, but as a Code Owner, you bear a greater responsibility for the code you own. You are expected to know and implement the standard and best way to work with that code and to educate others to do the same.
Addressing and helping with issues arising from code changes,
When changes are made to the codebase, it's important to address any potential issues that may arise. If an issue is discovered in an area of the codebase that has a designated Code Owner, both the Code Owner and the code contributor who made the change should work together to investigate and resolve the issue.
As the Code Owner, you have the deep knowledge, experience, and understanding of the code you are responsible for, making you the best equipped to help resolve any issues that may have arisen from recent changes. You should be willing to assist the code contributor in finding a solution to the issue, even if you didn't make the change yourself.
By working together to resolve issues quickly, you can help maintain the quality of the codebase and ensure the project stays on track.
Guiding Principles for Code Ownership
Here are a couple guiding principles of what a Code Owner is, versus what a Code Owner is not. Keeping these in mind will help you have a positive influence on others, as well as making your job as a Code Owner more effective.
Gardener, not Gatekeeper
The role of a Code Owner is not to act as a Gatekeeper, standing in front of a locked gate and barring access to others. This can lead to confusion and duplication of efforts, as well as reducing productivity for everyone. Instead, a Code Owner should view themselves as a gardener in a public garden, where everyone is welcome and encouraged to improve and look after the codebase.
As a Gardener, a Code Owner should make the code they own easy for others to navigate and understand, by ensuring it is well-documented, well-named, and well-structured. This helps reduce cognitive load for everyone involved in creating, reading, updating or changing the code in the Code Owner's domain. The Code Owner should also guide others around potential "thorns" in the garden, with the wisdom they have acquired, rather than blocking others and withholding information.
Teacher, not Judge
The role of a Code Owner is not to act as a Judge, rendering harsh criticisms and punishments for broken rules and unheeded guidelines. This creates a toxic culture that can prevent collaboration on the project and drive away talent. Instead, the Code Owner should strive to act as a teacher, showing others the way to correctly integrate changes and sharing their wisdom in the owned domain.
As a Teacher, the Code Owner guides others to learn from their own mistakes and increases others' sense of "ownership" as they contribute changes to the same area. This also helps to keep the "Bus Factor" high, meaning that more than just the Code Owner knows how the code works, reducing the risk of knowledge being lost if the Code Owner were to become unavailable. This creates a culture of learning that invites others to better understand the code, and it also enables the Code Owner to continue learning and growing in their own role.