working with
legacy code
Mark Jones
what is legacy code?
Legacy code is code not under test - Michael Feathers
Legacy code is code you're afraid to change - Mark Seemann
Code where the intention isn't clear, and hasn't had any love - Anon
Code nobody wants to work on - Anon
Legacy code is code that makes you laugh and/or cry - Mark Jones
Examples of legacy code
hard-baked dependencies
old technology
intention is unclear
What causes legacy code?
No ongoing design
No tdd
Consequences of untested code
When you change the code, you can't guarantee you won't break it
The code can't be refactored
Refactoring: "disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior" - Wikipedia
changes will be harder
bug count will
(almost certainly) increase
MORE manual testing
The code is expensive
why would code have no tests?
developer optimism
technical constraints
TIME CONSTRAINTS
How do you prevent Legacy code?
best practices
TDD
refactor to patterns
Keep code simple
keep code clean
Pair program
Peer code reviews
what is tech debt?
Quick hacks to get something out there - Anon
Knowingly writing bad code to deliver something on time - Anon
Stuff what's difficult or risky to change - Anon
The difference between the application that you would like to build and the application you actually build - Martin Fowler
The effort it takes to refactor your code to make it easy to add the next feature non-invasively- Michael Feathers
what causes tech debt?
Haste
Long-term architectural benefits are sacrificed for expedience
apathy
Not caring about solving known problems
Narrow-mindedness
The refusal to practice solutions that are otherwise widely known to be effective
sloth
Making poor decisions based on an easy answer
Avarice
Modelling excessive details, resulting in excessive complexity
Ignorance
The result of failing to seek understanding
pride
"Not Invented Here"
strategies for tech debt payback
improve
strangle
rewrite
replace
management buy-in
need time to develop clean code
need freedom to do the right thing
need to schedule tech debt payback
How to add tests to legacy code
run the code as far as you can
break dependencies
smallest changes POSSIBLE to code
sensing variables
coverage before refactoring
prove it's worked by changing code
tests then refactor
Tech debt
By Mark Jones
Tech debt
- 918