Code Categorization

Code Categorization in Allstacks

Overview
Code categorization is a powerful tool for understanding the focus and productivity of your development teams. By tracking the types of work being done in your codebase, you can gain valuable insights into team alignment, development efforts, and potential areas of improvement. This metric helps to normalize productivity, keep teams focused, and spot evolving challenges early.


What Does This Metric Measure?

Our algorithm categorizes code changes into six distinct categories to provide insights into your team's focus and overall development efforts. While code churn (frequent reworking of the same code) is generally undesirable, it can also highlight evolving requirements, learning new libraries, or technical challenges. These indicators are more about identifying patterns rather than managing them directly.


How Is This Metric Calculated?

Code categorization consists of six categories, each reflecting a specific type of work happening in your codebase. Here's a breakdown of each category:

  1. New Work
    This category tracks new features or new functionality added to the codebase.

    • Calculation: Net new or net removed lines of code that do not fall into any of the other categories.

  2. Legacy Refactor
    Focuses on addressing technical debt by refactoring or improving older code.

    • Calculation: Identified by analyzing code replacements or updates in code that hasn’t been worked on for more than 60 days.

  3. Help Others
    Represents a developer or team member working on a feature or product that was not originally theirs.

    • Calculation: If a developer works on a code section or file they don’t usually contribute to (e.g., no prior commits in that file), the work is categorized as "Help Others."

  4. Churn
    Tracks code that has been repeatedly modified, usually to fix bugs or rework code.

    • Calculation: Identified as code that has been rewritten across 2 or more commits in the past 30 days.

  5. Library
    Represents external code imported into the project, such as libraries or third-party packages.

    • Calculation: Identified by large files (over 100 lines) with no modifications to individual lines, indicating that they are added as-is from external sources.

  6. Comments
    Measures the amount of in-code documentation (comments).

    • Calculation: Based on the presence of block comments or multi-line comments in popular file types. Trailing comments (on the same line as code) are considered part of the code.


What Questions Can This Data Help Answer?

This metric can provide insights into various aspects of your team's development process:

  1. What type of code is my team writing?
    Understand the balance of work types, from new features to refactoring efforts and technical debt management.

  2. How is the type of code my team is writing changing over time?
    Track how the focus of the team shifts (e.g., moving from new feature development to refactoring or addressing churn).

  3. What type of code is my team writing, grouped by category?
    View a breakdown of contributions to different categories (New Work, Legacy Refactor, Churn, etc.) for better visibility.

  4. Does the distribution of work align with the team's initiatives?
    Ensure that the focus of your team matches organizational priorities and initiatives, such as feature development vs. addressing technical debt.


Key Takeaways from This Data

  1. Balance Between New Features and Refactoring
    If you’re deploying new features but see a high amount of Legacy Refactor, it may indicate that your team is spending too much time addressing technical debt. This warrants a conversation to understand the balance and priorities of the team.

  2. High Code Churn
    A high amount of code churn may indicate a developer who is “spinning their wheels” or struggling to stabilize certain features. It can also suggest future technical debt and potential code quality challenges. It’s important to monitor and address these issues to maintain long-term code quality.

  3. Team Focus and Alignment
    By examining the proportion of work in each category, you can better understand whether the team is focused on the right initiatives. For example, if "Help Others" is high, it might indicate a collaborative team effort, but if it’s too high, it might suggest that certain areas of the codebase lack ownership or expertise.


Conclusion

Code categorization provides valuable insights into your development team’s focus, work patterns, and areas of potential concern. By understanding the balance between new features, technical debt, refactoring, and other types of work, you can help your team stay aligned with organizational goals, maintain code quality, and address emerging challenges in a timely manner.