Testing Legacy Code & Refactoring Patterns
summary
Practical Java refactor recipes that keep public signatures intact: use IntelliJ refactor actions (Control‑Alt‑Shift‑T, Shift‑F6, Control‑Shift‑T) to extract delegate/class (phone number from Person), extract interface (TokenWallet), and introduce functional parameters to remove new/static calls so tests avoid PowerMock. Demo projects include a three‑class Blackjack and wallet; patterns shown: decorator via wrap class, sprout method/class, parameterized constructor. Claims: duplicate then refactor wins over heavy mocking, lambdas simplify tests, and TDD works in brownfield code.
AI-written summary · about
chapters (14)
- 0:00Introduction to legacy code
- 2:08Legacy code principles
- 6:06Test-driven development
- 11:17Testing and mocking
- 12:51Extract delegate pattern
- 17:16Refactoring in IntelliJ
- 25:01Extract interface pattern
- 29:30Parameterizing methods
- 32:53Overcoming static calls
- 37:54Constructor refactoring
- 42:29Sprout and wrap patterns
- 47:02Decorator pattern
- 52:20Advanced refactoring tools
- 55:52Refactoring best practices
related talks
44mRefactoring Legacy Code Guided by Simple Design
46mRefactoring Legacy Code guided by Simple Design
42mWorking Effectively with (Android) Legacy Code
35mRefactoring Frenzy - Don't settle for short term
37mWorking Effectively with Android Legacy Code
47mBottega IL: Live refactoring towards solid code
01h 01mYou Can Test Anything
49mSurviving a Legacy Codebase
