← All learnings

Leadership

Rewrite or modernize in place: the question that decides the plan

When someone on a large app says the word rewrite, the conversation usually goes straight to architecture: which modules, which UI toolkit, which patterns. That's the wrong place to start. Before any of it, the team has to answer one question, because the answer changes the whole plan.

The question is this: can feature work stop while we do it?

If it can, you're free to rebuild the app from scratch. If it can't, and it usually can't, you modernize the app you have while it keeps shipping. Those are two different projects, with different repositories, team shapes, risks and timelines. This post covers both, and the step they both depend on: agreement from everyone affected before anyone writes the first line.

One question, two plansdecide this before anything else
Can feature work stop while we rebuild?The honest answer, from the people who own the roadmap
Yes · full rewrite
A new app in a new repository
All hands on the rewrite
The old app gets fixes only
Value arrives at the cutover
No · modernize in place
Same app, same repository
Foundations first, then feature by feature
Bridges between old and new code
Value arrives with every release
both paths start with the same step: buy-in from everyone affected
The architecture can be identical at the end. The road there isn't.

Ask the question first, and get a real answer

A vague answer is the most dangerous one. "We'll slow features down a bit" means the features continue, the rewrite gets whatever time is left, and a year later there are two half-finished apps. So I ask the question in a way that forces a precise answer:

  • Is there a date after which no new feature goes into the current app, and who agreed to it?
  • Which promises to customers or partners fall inside that period?
  • If a high-priority request arrives in month three, what happens to it?

If those questions have clear answers, a full rewrite is possible. If they don't, the project is a modernization in place, whatever the kickoff meeting called it. Name it correctly on day one, and the team won't plan one project and then live through the other.

Path one: the full rewrite

With real freedom, the cleanest route is a new app in a new repository, with the whole team on it. There's no legacy code in the way, no bridge to maintain and no build that has to hold two architectures at once. The team sets the module structure, the patterns and the checks on day one, and every line follows the new standard.

That freedom is real, and so is the cost. Nothing reaches users until the new app replaces the old one, so the whole investment is at risk until the cutover. The plan has to account for that:

  • Write the parity list first. Go through the old app screen by screen and record what it does, including the behavior nobody remembers deciding on. Agree with product on what moves to the new app, what goes away and what changes. That list is the scope. Without it, the finish line keeps moving.
  • Build one slice end to end before you spread out. Take one real feature through the network, storage, UI, tests and release pipeline. It proves the architecture on something that matters and gives the rest of the team a pattern to copy.
  • Put the old app in maintenance. Critical fixes only, with a named owner, so the old app stays healthy and people don't keep getting pulled back into it.
  • Show progress on a schedule. A rewrite ships nothing for a long time, so demos are how stakeholders see their investment. A working build every few weeks keeps their trust.
  • Plan the cutover as its own project. Current users have data, sessions and settings on their devices. Decide how that data migrates on first launch, release in stages and keep the ability to halt the rollout.

The cutover deserves the most technical care, because it's the one step every user feels:

  • Keep the package name and the signing key. Android installs the new app as an update only if both match and the version code is higher. Then the user's database, files and Keystore keys stay with the app.
  • Migrate data in code you can test. Room migrations run against the real old schemas with MigrationTestHelper, and SharedPreferences move to DataStore through SharedPreferencesMigration. Anything you can't migrate safely gets a deliberate fallback, like a fresh sign-in, never a crash.
  • Release in stages and watch the right numbers. A staged rollout on Google Play can be halted at any percentage. Crash-free sessions, ANRs, sign-in success and the app's main business metric decide whether it continues.

The risk to watch is ambition. With an empty repository, it's easy to redesign every feature along the way. Each improvement is reasonable, and together they double the timeline. The rule that keeps a rewrite finite: parity first, improvements after the cutover.

Path two: modernize in place

When features have to keep shipping, the rewrite happens inside the app, within clear boundaries. The goal is the same architecture. The difference is that the app is never broken and never frozen, and old and new code live side by side for as long as it takes.

Martin Fowler named this approach the Strangler Fig pattern. New code grows around the old app and takes over one feature at a time, until the old code has nothing left to do.

Order matters more here than on the other path:

  1. Draw the boundaries. Decide the module structure and the rules between modules before you move any code. Enforce them in the build so the new area stays clean from the first commit.
  2. Set up the foundations. The network layer, analytics, configuration, the design system and the other shared capabilities move into core modules behind narrow interfaces. Every feature depends on them, so they come first.
  3. Modernize one feature at a time. Each feature moves into its own modules and ships when it's ready.
  4. Plan the work with the roadmap, not against it. The best time to modernize a feature is when product plans changes to it anyway. The team is already in that code, the test effort is already budgeted, and the new roadmap work lands on the new foundation.

That last point is what makes this path sustainable. A modernization that competes with the roadmap loses eventually. One that travels with the roadmap gets its budget from the roadmap. I describe the technical order in Breaking an Android monolith.

Bridges between old and new

For months, a modernized feature has to work next to code that hasn't moved yet. The new search screen needs the signed-in user, and the user still lives in a legacy singleton. An old screen has to open a new one. This is where the project succeeds or fails. The shortcut is new code that uses old code directly, and that shortcut slowly rebuilds the tangle.

The answer is a bridge: a small adapter that serves old data through a new contract.

KLegacySessionBridge.kt:core-session and :app
// :core-session (new code). Modernized features depend on this and nothing else.data class Session(val userId: String, val displayName: String)interface SessionRepository {    val session: StateFlow<Session?>    suspend fun signOut()}// :app (the bridge). The only class in the new world that knows the legacy one exists.internal class LegacySessionBridge(    private val legacy: LegacySessionManager,    private val ioDispatcher: CoroutineDispatcher,) : SessionRepository {    private val _session = MutableStateFlow(legacy.currentUser()?.toSession())    override val session: StateFlow<Session?> = _session.asStateFlow()    init {        // The legacy code stays the owner of the data until it is migrated.        legacy.addListener { user -> _session.value = user?.toSession() }    }    override suspend fun signOut() = withContext(ioDispatcher) { legacy.logoutBlocking() }}private fun LegacyUser.toSession() = Session(userId = id, displayName = displayName)

New features only see SessionRepository. They can't tell whether the data comes from the legacy manager or a rewritten session module, and they don't need to. When the session code is modernized, you delete the bridge, a real implementation takes its place, and no feature changes.

Bridges are temporary by design, but they only stay temporary if someone manages them:

  • Dependencies point in one direction. New code defines the interface. The bridge implements it and is the only code that touches the legacy class.
  • Bridges live in one place. They sit in the app module or a dedicated bridge module, never in the features, so anyone can see how much legacy code still carries load.
  • The old code stays the owner. Until you migrate a piece of data, it has one source of truth, and the bridge reads from it. Two copies you keep in sync are a bug waiting for a release.
  • Each bridge has an owner and an exit. A bridge with no removal plan becomes permanent architecture. The number of remaining bridges is one of the clearest measures of progress.

Where old and new screens meet

Data isn't the only seam. For months, old screens open new ones and the other way round, often in the same back stack. Both directions have a supported answer, and neither needs a rewrite of the host screen:

KSearchHostFragment.ktlegacy app module
// A legacy Fragment hosts a modernized Compose screenclass SearchHostFragment : Fragment() {    override fun onCreateView(        inflater: LayoutInflater,        container: ViewGroup?,        savedInstanceState: Bundle?,    ): View = ComposeView(requireContext()).apply {        // dispose with the Fragment's view, not with the window        setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)        setContent { AppTheme { SearchRoute() } }    }}

In the other direction, AndroidFragment from fragment-compose embeds an old Fragment inside a Compose screen, so a new screen doesn't wait for every child to migrate. Navigation follows the same rule as data. The new code defines a small navigator interface, :app implements it, and only :app knows whether a route opens an Activity, a Fragment or a Compose destination.

Each swap also ships behind a remote flag that can send users back to the old screen. The flag, the old screen and the bridge are deleted together, in one release, once the new screen has held up in production.

The two paths side by side

Full rewriteModernize in place
Feature workStops, by agreementContinues throughout
Where the code livesA new repositoryThe current one, behind new boundaries
TeamEveryone on the rewriteShared between roadmap and modernization
When users benefitAt the cutoverWith each modernized feature
Old and new togetherNever in one buildFor the whole project, through bridges
Biggest riskScope growth and a late, large launchA stop halfway, with bridges that never leave
What leadership must acceptA period with no new featuresA longer timeline and slower features for a while

Neither path is better in general. A full rewrite is faster and cleaner when the freeze is real. A modernization in place is safer when it isn't, and it's the only honest option when the business can't pause.

Buy-in comes before code

Both paths ask a lot of people outside the team. One asks product to stop new releases. The other asks for patience while features take longer. Neither survives if the people affected first hear about the cost when it hits them. So before any code, I treat alignment as its own deliverable, and I expect to present the plan more than once, to more than one audience.

Same plan, different presentationswhat each audience needs to hear
Leadershipwhat no action costs, what this costs, when it pays back
Productwhat pauses or slows, for how long, and what they get after
Engineersthe target architecture, the rules and how their daily work changes
QA and releasehow regressions are contained and how a rollout can be stopped
Design and partner teamswhat stays the same for users and where they will be asked for input
One deck for every audience answers none of them well.

What makes those conversations work:

  • Start with the problem in their terms. Leadership doesn't feel coupling. They feel features that take twice as long as they used to, and releases that slip. Start with what they already see.
  • Bring options, not a verdict. Show both paths with their costs, and include a third option: no action. People commit to a decision they helped make.
  • Be exact about the price. Say what will pause, what will slow and for how long. A plan that hides its cost loses its sponsors the moment the cost shows.
  • Agree on how to measure progress. Modules migrated, bridges remaining, build time, stability. Pick the numbers together, then report them on a schedule.
  • Expect to present it again. Priorities change and people change roles. Buy-in gets renewed with every update. You don't win it once in a kickoff.

Keep the plan honest after the start

The plan is the easy part. The result depends on whether it still holds six months later:

  • Make the rules automatic. Boundaries the build enforces hold when the team is busy. Boundaries that only review enforces don't.
  • Do the hardest part yourself. The first module, the first bridge and the worst piece of legacy code set the patterns. A leader does that work instead of only assigning it.
  • Teach people as you go. A rewrite is the best training a team gets. Pair on the first feature, then hand the next one to the team.
  • Define done as deleted. When the new code ships, you're only halfway. A feature is done when its old code and its bridge are gone.

The short version

  • Ask whether feature work can stop, and don't accept a vague answer.
  • If it can, build a new app in a new repository, hold to parity and plan the cutover early.
  • If it can't, modernize in place: boundaries, foundations, then one feature at a time, with the roadmap.
  • Old and new code meet only through bridges, and every bridge has an exit.
  • For a cutover, keep the package name and signing key, and test every data migration.
  • Swap screens behind flags, and delete the flag, the old screen and the bridge together.
  • On either path, get buy-in first, with a presentation for each audience.

The architecture is the part everyone wants to discuss first, and at the start it matters least. Get a real answer to the one question, show everyone the price, and make the rules automatic. The modules follow from there.