"Drive-by patching" (or sometimes "drive-by fix") in the context of ticket resolution refers to a situation where a developer or technician, while working on a different ticket or project, notices a small, seemingly straightforward bug or issue and fixes it "on the fly" without formally creating a separate ticket for it. Think of it like a mechanic noticing a loose bolt while changing your oil and tightening it without making a whole new work order.
Here's a breakdown of the key aspects and implications:
Characteristics:
- Opportunistic: The fix happens because the developer is already in the relevant code or system area.
- Small and Simple: Typically involves a minor code change, configuration tweak, or easily addressed problem. It shouldn't require extensive investigation or impact other areas significantly.
- Unplanned: The fix wasn't originally scheduled or formally requested.
- May or May Not Be Documented Well: Here's the biggest potential problem. Sometimes it's documented in the original ticket's comments, but often it's not documented anywhere, leaving a hidden change.
Potential Benefits:
- Efficiency: Quick resolution of minor annoyances without creating bureaucratic overhead.
- Improved Code Quality: Addresses small defects that, if left unchecked, could accumulate or cause minor problems later.
- Proactive Problem Solving: Prevents minor issues from escalating into larger, more complex problems.
Potential Risks and Drawbacks:
- Lack of Traceability: If the change isn't properly documented, it can be difficult to understand why the code was modified later, leading to confusion or accidental regressions.
- Testing Issues: Because it's unplanned, there may be inadequate testing of the fix, potentially introducing new bugs.
- Unintended Consequences: Even seemingly small changes can sometimes have unexpected side effects. Without proper planning and testing, you risk breaking something else.
- Violation of Change Management Processes: Drive-by patching can bypass formal change control procedures, leading to auditing and compliance issues (especially in regulated environments).
- "Technical Debt" Accumulation: A series of undocumented or poorly tested drive-by patches can create a messy codebase that is difficult to maintain in the long run.
- Scope Creep (Sort Of): While not exactly scope creep in the traditional project sense, it can add undocumented changes to the system, making understanding the original ticket's purpose harder to discern over time.
Example:
Imagine a developer working on a ticket to implement a new feature on a website. While editing a specific template file, they notice a typo in a label. They fix the typo as part of their work on the primary feature ticket. That's a drive-by patch.
When It's (Sometimes) Acceptable:
- Extremely Trivial Fixes: Correcting typos, minor formatting issues, or adjusting simple configuration settings.
- Full Documentation: The fix must be clearly documented in the original ticket comments (at a minimum) or, ideally, in a separate commit message. Include why the change was made.
- Adequate Testing: Even minor fixes should be tested to ensure they don't introduce new problems.
- Good Version Control Practices: Use commit messages to clearly indicate the reason for the change.
- Strong Code Review Practices (if applicable): Even if the fix is small, consider having another developer review the change.
Best Practices to Mitigate Risks:
- Document Everything: If you make a drive-by patch, always document it. At a minimum, add a comment to the ticket explaining the fix and why it was made. Ideally, include it in a meaningful commit message in your version control system.
- Prioritize Formal Ticketing: For anything beyond the most trivial fix, create a separate ticket to track the issue properly.
- Follow Established Change Management Processes: Adhere to your organization's change management policies, even for small changes. This may involve getting approval before implementing the fix.
- Communicate with the Ticket Owner: If you're fixing something related to a ticket someone else is working on, let them know what you've changed.
- Train Developers: Ensure developers understand the risks of drive-by patching and the importance of proper documentation and testing.
- Encourage Code Reviews: Even for small changes, code reviews can help catch potential issues.
In summary:
Drive-by patching can be tempting for its efficiency, but the potential risks often outweigh the benefits. While it might be acceptable for the most trivial fixes, proper documentation, testing, and adherence to change management processes are crucial to prevent long-term problems. It's generally better to create a separate ticket for anything beyond a very minor, obvious fix.