What is legacy code?

'code without tests'

Reasons to change code


Edit and pray

Cover and modify

Characterisation Tests

Test what the software ACTUALLY DOES

Legacy code dilemma

Change requires code to be covered by tests, but code needs changing to bring it under test...

Refactoring tools!!


'a place where you can alter behaviour in your program without editing in that place'

Enabling points

Refactoring methods

Sprout method


1st attempt

Just think of the SRP!

Sprout method

TDD GetUniquePosts()