Klaus Breyer Tech Leadership, Product Delivery & Startup Strategy.

Refactoring Legacy Code in Shape Up: The Dilemma

Introduction

Legacy code is the proverbial elephant in the room. The nagging issue isn’t “if” it should be refactored, but “when” and “how.” When following the Shape Up methodology, the tech lead has two main options.

The Dedicated Tech Sprint

This is a ‘clean-up’ cycle, usually directed by the tech lead and staffed by one or two more devs. The objective: navigate the labyrinth of legacy code.

The Game Plan

Before the first line of code is altered, there’s shaping to be done. The tech lead joins forces with the product team to draft a basic plan, complete with goals and desired outcomes. This isn’t aimless tinkering; it’s a planned operation.

Pros and Cons

  • Pros: Undivided attention. The tech lead and team become code surgeons for a cycle.
  • Cons: All other projects take a back seat. No new bells and whistles for the end-users.

The Blend: Limited Features and Refactoring

Here, refactoring isn’t elongating the timeline; it’s limiting the number of new features that can be rolled out. Fixed time, variable scope.

The Game Plan

Shaping takes on a dual role here, and the tech lead must ensure engineers are deeply engaged. They’re not just constructing new features; they’re also retrofitting the old. The trade-offs are transparent.

Pros and Cons

  • Pros: There’s still forward momentum. Some new features do make it out.
  • Cons: Complexity is a given. Juggling the old and the new could invite the second-system effect.

Here’s Where It Gets Tricky

A dedicated tech sprint is a tech purist’s dream—clean code, no scope creep. But the reality check: refactored code needs to be checked in both old and new use cases. Post-refactoring, bugs often slip through the cracks due to inadequate testing.

The Answer?

It’s context-sensitive. It pivots on various factors like deadlines, team dynamics, and more. And remember, shaping is not just a feature game; it’s also about architecture. A technical shaper, often the tech lead, should spearhead the effort and consult with the broader engineering team.

Conclusion

The dilemma is real, but so are the solutions. Choose carefully.

There you have it. Two methods, pros and cons, and a whole lot of context. Choose wisely.