Refactoring Legacy Code guided by Simple Design
summary
Walks a messy Java production module down to a safe-to-change shape by deleting dead code, moving constants into consumers, extracting methods, renaming for intent, and adding characterization tests that lock current behavior. Uses Eclipse shortcuts, UC Detector to find unused publics, Mockito for mocks, and EclEmma/Emma for coverage. Starts from a file util claimed at ~500,000 lines, spends about 1.5–2 hours of work, gets full coverage on the focal method, and checks incremental commits proving the refactor compiles and tests pass.
AI-written summary · about
chapters (15)
- 0:00Intro
- 1:25Code base overview
- 2:41Legacy codebase overview
- 6:09Find more dead code
- 7:02Delete unused methods
- 11:30Remove unneeded classes
- 16:42Rename vigorously
- 17:45Extract method
- 19:41Characterization tests
- 28:39Unit tests
- 31:01Extract code
- 33:26Illegal argument exception
- 33:59Job parameters
- 36:16Mocks
- 41:15Ifelse
related talks
01h 00mTesting Legacy Code & Refactoring Patterns
42mWorking Effectively with (Android) Legacy Code
43mFrom 0% to Cleanly Refactored 100% tested code
38mSurgical Refactoring of Non-Tested Code – A Worked Example
33mTo Refactor or Not: How to Systematically Modernize Your Java Applications
55mModernizing Legacy Code - While Not Bringing Down Prod
01h 31mClean(er) Code for Large Scale Legacy Applications
01h 29mAlchemical Code Rejuvenation
