Surgical Refactoring of Non-Tested Code – A Worked Example
summary
Method extracts impure chunks from a small C++ trivia codebase, converts the deterministic parts into pure functions, moves them into a separate file (CLion and compiler errors guide dependency injection), and adds data-driven tests (and notes how to use property-based tests or Spock in JVM languages). Refactoring collapses duplicated creators into a single generator, then groups helpers into classes; the process produces a tested result with 167 assertions checked and incremental commits to keep behavior unchanged.
AI-written summary · about
chapters (6)
- 0:00Start
- 0:06Alexandre Bobwaka
- 9:17Refactoring Move Function
- 12:27Data-Driven Tests Approach
- 26:37Test Separation
- 31:43How Do You Move Pure Functions into a Class
related talks
49mWorking with C++ Legacy Code
45mWorking with C++ Legacy Code
43mFrom 0% to Cleanly Refactored 100% tested code
01h 02mRefactoring C++ Code for Unit testing with Dependency Injection
01h 31mClean(er) Code for Large Scale Legacy Applications
40mTesting Legacy Code: Safe Refactoring
46mRefactoring Legacy Code guided by Simple Design
34mBetter Code Through Boring(er) Tests
