Working Effectively with (Android) Legacy Code
summary
Provides concrete micro‑refactors that turn untestable Android Java code into testable seams: find object seams, break singletons like a DatabaseManager with a static setter, replace static util calls with instance delegators, and split god objects via extract interface so presenters accept mocks. Shows runnable examples (NotificationFactory, login presenter, event tracker) and a decorator wrap class for tracking without changing legacy code. Recommends incremental tests first and measures wins (example: swapped GSON to Mashi and validated serialization performance improvements).
AI-written summary · about
chapters (19)
- 0:00Introduction to legacy code
- 1:09Defining legacy code challenges
- 4:24Why legacy code is untestable
- 7:37Reasons to modify legacy code
- 9:25Understanding seams in code
- 10:49Demo: Finding seams in activities
- 13:38Dependency breaking techniques
- 16:28Handling singletons in tests
- 18:56Breaking static method dependencies
- 20:45Extracting interfaces for god objects
- 22:54Extracting implementers for interfaces
- 25:01Sprout method technique
- 28:53Sprout class strategy
- 31:03Wrap class burrito strategy
- 34:59Key takeaways and next steps
- 37:48Q&A: Rewriting vs refactoring
- 39:09Q&A: Regression testing
- 40:11Q&A: Refactoring approach
- 41:14Q&A: Java to Kotlin migration
related talks
37mWorking Effectively with Android Legacy Code
41mHow to Really Test an Android Application
18mRescuing Old Code with JetPack
42mIngredients for a healthy codebase (en)
46mRefactoring Legacy Code guided by Simple Design
29mLet's get functional
40mProtips: A fresh look at advanced topics for Android experts
41mUnit Test Your Code, Even Your UI!
