Dissolving Technical Debt on Agile Projects - Smidig 2012

Preview:

DESCRIPTION

Experiences with dealing with legacy code while delivering value. Key points: 1) Legacy code costs a lot. 2) Design must be maintained & evolved. 3) Continous refactoring during each task is a way to achieve 2.

Citation preview

An Agile Approach to Technical Debt

Is The Only Way

Jakub Holý @ iterate no

Origins

by Jon Baldock nz @ flickr

We've all been there - mess of code

by Ignaz Wiradi @ wikimedia

What we would like to have- clean, structured, fitting

by cotallo-nonocot @ flickr

What we do have. It (likely) started with st. small & clean but requirements evolved while the design of the code did not - only hacked & patched

God class

● 15 kLOC● 300 properties● 320 methods● 50 constants● used everywhere

by mandalinarossa @ flickr

Example of legacy - a typical monstrous god class that we were confronted with.

The pain!

It was pain!

True cost of legacy

Pain <= Time wasted in code archeology, money & time wasted due to bugs being introduced.Legacy code matters to business for real money are wasted there.

Escape???

Refactor!

The only way out is to improve the design

?

How do we get from L to R? The sad answer is we don't.It took centuries to build R. We can never get from L to R in a reasonable time. There is too much mess, too much to fix.

Code Churn

Michael Feathers: Getting Empirical about Refactoring

Code-churn driven refactoring: improve where it matters & pays off most - complex & changed often

=> Boy Scout Refactoring

● Only task-related● Time-boxed● Always● (+ TDD)

Refactoring can go on forever => focus, time-box. Task related => in code that matters most now/in near future. (We: 1/3 every task devoted to refactoring.)

Refactoring: Improving the Design of Existing CodeMartin Fowler

Working Effectively with Legacy CodeMichael Feathers

Behead Your Legacy Beast: The Mikado MethodD. Brolund, O. Ellnestam

It worked!

Required:

Management endorsement

True cost of legacy

Show to your management; Legacy code = lot of money lost.

Challenge

Large-scale refactorings● risky => avoid● sometimes necessary● boy scout rule doesn't help

Summary

● Design needs love● Continuous, focused, time-boxed refactoring● True cost of legacy

You too can do it!

TeachLearnUnify

ObserveEvaluateAdjust

改善

Recommended

Retrospectives: Group code reviews:

Something that worked great for us

Questions?

@HolyJakjakub.holy@iterate.no

theholyjava.wordpress.com