Glossary Background Image

No Bad Questions About DevOps

Definition of Trunk-based development (TBD)

What is trunk-based development?

Trunk-based development (TBD) is a method for tracking and controlling software source code that allows developers to make changes to small pieces of code, which they can then merge with the main part of the code, called the "trunk." As opposed to other approaches, TBD gives developers access to the trunk in order to seamlessly integrate continuous integration (CI) and continuous deployment (CD) within their projects and to iterate quickly. This ensures that shippable code is always available in a product, meaning changes that developers add to the source code don't break the build or conflict with other changes during a merge.

TBD has become very popular in software development and is now an integral part of CI/CD due to the benefits it provides:

  • Continuous code integration: Due to the small size of changes and automation in TBD, new code can be easily and steadily integrated into the source code.
  • Continuous code review: The small size also reduces the time spent on code review. Developers can easily see what changes were made to ensure they won't cause any conflicts when merged.
  • Consecutive production code releases: When teams are expected to release new features and even products quickly, TBD gives them a framework.

What is feature-driven development?

Feature-driven development (FDD) is, as its name suggests, an approach to development that is organized around features. It includes short iterations with frequent releases. FDD allows developers to prioritize client requests and desires concerning a product's development. This is done by outlining what features a client wants, breaking down the request into smaller tasks, and then creating a plan to realize each goal given the required time. FDD works best in large development teams that adhere to development standards and have products that need quick releases. Smaller teams should use other methodologies, such as Git Flow.

The key difference between this approach and trunk-based development is that in FDD, developers only have access to the specific part of the code they need for the feature they are creating. In TBD, developers have access to a shared codebase.

When to use trunk-based development?

TBD is great for delivering frequently on fast-paced projects. However, it requires teams to have the following characteristics and skills:

  • High level of collaboration and communication: To ensure that no one causes any harm to the source code.
  • Robust testing process: Adopt a culture of testing and commitment to using testing automation tools.
  • Disciplined: Accept the importance of following standards and best practices to maintain coding and testing at the same level across all developers.

Given the risks connected with directly changing the main branch of code, these characteristics are essential. Evaluating your team and project is important to determine if TBD is the right approach for your situation.

An alternative to TBD could be GitFlow. This approach doesn't let developers make changes directly to the trunk. Instead, there are several branches where changes are made and tested until a feature can be merged into the main trunk. The extra steps could be suitable for teams that haven't developed the discipline required for TBD. Likewise, GitFlow suits developers who are working on long-term projects with multiple versions and releases. The downside is an increase in the potential for the changes to conflict with each other once they enter the main branch.

Key Takeaways

  • Trunk-based development (TBD) is a method for tracking and controlling software source code where developers make changes directly to small pieces of the source code and then merge these changes into the "trunk."
  • TBD is best for teams working on fast-paced projects that need to release features frequently.
  • These teams should have a high level of collaboration and communication and adhere to a test-first culture, as well as standards and best practices in software development.
  • An alternative to TBD is Gitflow, which adds additional branches where developers can change their code, thereby separating them from the source code.

More terms related to DevOps