The unit of work is one seam moved.
The durable artifacts are the characterization tests, the adapters, and the list of old code still in use. The main hazard is a large diff that cannot be reviewed or reverted.
Trace a screen migration. The fragment’s logic moves into a plain class with tests. The fragment calls that class. A composable replaces the view and uses the same class. The fragment is deleted last. Each step builds and runs.
Capture the baseline with the verify script on the legacy project. Write three characterization tests for one function. Move that function behind an interface, and confirm the tests still pass without edits.
Review the tests before the code. Ask whether the characterization tests existed before the change, and whether they changed in the same commit as the code. A changed expected value in a migration is the first thing to question.
When a migration shows a regression, bisect by step. Because each step was small and built, the first failing commit names the cause. If steps were large, the bisect ends in a 2,000 line diff.
Legacy code often holds old risks: cleartext endpoints, a world-readable file, a permissive WebView, a dependency from a closed repository. Inventory them, rank them, and fix them as separate tasks with their own tests.
Verify against old data. Keep fixtures from every released stored format, and test the migration from each. Verify behavior with characterization tests, and verify the seam with a test that a cancelled caller cancels the old work.
Never mix a migration with a feature. Keep a list of adapters with owners and removal dates. Review the list at each release and delete what you can.
- A one-command build and a recorded baseline exist.
- Characterization tests were written before the change.
- Each step builds and passes.
- Adapters cancel old work and ignore late results.
- Stored data is backed up before it is migrated.
- Why must the characterization test be written first?
- What goes wrong if a screen’s logic and view are migrated together?
- What does the adapter do with a second callback?
- Why does the migration test start from a literal file?
Continue with the book
Explore the full treatment, worked examples, and exercises in Agentic Android App Development.
Companion article for Agentic Android App Development, published by Choral Software. Article text and original examples © 2026 Choral Software. All rights reserved.
