57
Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

Embed Size (px)

Citation preview

Page 1: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

1

Credit Crunch Code

Paying Back the Technical DebtBy Gary Short

Page 2: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

2

Agenda

• Admin• Defining Technical Debt• Why Managing Technical Debt is Important• Quantifying Technical Debt• Technical Debt Anti-Patterns & Fixes• Finding Technical Debt Using Metrics• Summary• Further Reading• Questions.

Page 3: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

3

Defining Technical Debt #1

Page 4: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

4

Defining Technical Debt #2

• With financial debt– “Virtual debt” by not having the best interest rate

• With Technical Debt– Not making savings against time where possible.

Page 5: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

5

Biggest Technical Debt EVA?

Page 6: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

6

Is There Interest On Technical Debt?

• Just as there is interest on financial debt...• So there is interest on technical debt too:– Cost later – cost now– Financial value of damage to your brand– Loss of market share– Low staff morale.

Page 7: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

7

Just As Not All Financial Debt Is Bad

Borrow

BuildSell

Repay

Page 8: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

8

Nor Is All Technical Debt

Borrow

BuildDeploy

Repay

Page 9: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

9

But Financial Debt Can Be Dangerous

Page 10: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

10

And So Can Technical Debt

Page 11: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

11

Why Is Managing Technical Debt Important?

January February March April May June0

1

2

3

4

5

6

7

8

9

Unmanaged Technical Debt Over Time

Page 12: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

12

Reduce Effort by Keeping it Under Control

January February March April May June0

1

2

3

4

5

6

Managed Technical Debt Over Time

Page 13: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

13

Quantifying Technical Debt

Page 14: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

14

Basic Formula To Get You Started

Bba

XSLHIHPHi

Ti

1i

EOC..HRi

Where:T = Total number of employees involved in paying back the debti = The individual employeeHRi = Hourly rate of pay for that individualHi = The hours that an individual worked in paying back the debtEOC = Employer’s on cost – estimated at 40% of salary = 140% of salaryHP = Purchase cost of any hardware requiredHI = Installation cost of any hardware requiredSL= Cost of any software licencesX/Bba = An estimate of the damage to brand image.

Page 15: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

15

Rate Card

• Project Manager = 32 Euros / hour• Architect = 33 Euros / hour• Lead Developer = 30 Euros / hour• Developer = 26 Euros / hour• Tester = 20 Euros / hour• Tech. Support = 15 Euros / hour• Business Analyst = 32 Euros / hour.

*Hourly rate = average annual salary / (52 – 5wks AL * 5 – 9 days PH * 8 hrs)**UK hourly rate converted to Euros via Google ***Correct as of November ’09. YMMV

Page 16: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

16

Case Study #1

• The Anti-Pattern: Waterfall Methodology

Page 17: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

17

The Main Weakness of Waterfall

1 2 3 4 5 6 7 8 9 10

Cost of Change Over Time

Page 18: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

18

Where Does Change Come From?

1 2 3 4 5 6 7 8 9 10

SME Knowledge Over Time

Page 19: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

19

Why is Change So Costly?

1 2 3 4 5 6 7 8 9 10

SME Knowledge Over Time

1 2 3 4 5 6 7 8 9 10

Cost of Change Over Time

Page 20: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

20

Why Is This Technical Debt?

• Borrow time now, repay later• Take advantages now– Ease in analysing potential changes– Ease of coordinating large teams– Precise budgeting

• Repay later– Extra cost of change.

Page 21: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

21

Quantify the Technical Debt: Agile

• Assume a small error caught during the “paper prototype” phase of an iteration

• Resources deployed– Architect spends 1 hour fixing design– Tester spends 1/2 hour verifying the fix– Apply those figures to our formula and:

• Cost of fixing the error = 60 Euros.

Page 22: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

22

Quantify the Technical Debt: BDUF

• Now the same error found in waterfall...• Resources deployed– Architect 1 hour fixing design– Developer spends 4 hours coding solution– Lead developer spends ½ hour peer review– Tester spends 2 hours verifying fix– Apply those figures to our formula and:

• Cost of fixing the error = 208 Euros• Value of the technical debt = 148 Euros.

Page 23: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

23

Potential Cost Per Project

• So the TD / defect = 148 Euros• The av. number of defects / project = 283*

• Potential TD / project = 41,884 Euros.

*Source: Scan 2006 Benchmark (as of March 2008)

Page 24: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

24

Fixing The Technical Debt

• I’m not saying prefer Agile over Waterfall• I am saying:– Be aware of the impact that might have on TD• Think about how you are going to combat that:

– Review earlier in the process where change is cheap– Ensure the SME has peer review– Regular, early checks on design vs coded solution

• Don’t leave all testing to the last phase.

Page 25: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

25

Case Study #2

• The Anti – Pattern: Not Invented Here

Page 26: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

26

Symptoms

• Development team spend time developing software which is not core the problem they are trying to solve

• Instead of buying in a third party solution• They justify this by saying things like:– It doesn’t work the way we need it to– It would take me as long to write as to learn API– The 3rd party may go bust– The code isn’t good enough quality.

Page 27: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

27

Concrete Example

• Developers for a national bank are tasked with creating a new MIS tool

• They dedicate 1 developer full time to creating a charting component

• This sucks in testing and PM time too• Charting component not core to task at hand• Spent 3 months getting nowhere• Before buying a charting component.

Page 28: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

28

Why Is This Technical Debt?

• Savings against time not made• Chose to develop a component• Should have bought from a third party.

Page 29: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

29

Quantifying The Technical Debt

• The component was bought in the end:– Disregard the cost of the component– And the time spent learning the API

• Resources deployed:– 1 X developer 3 months– 1 X tester 1.5 months– 1 X lead developer 1 day– 1 X PM 1 day

• Cost of technical debt : 24,886 Euros

Page 30: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

30

Fixing The Technical Debt

• Identify non core functional aspects of project– For each of those:• Can a component be bought in to achieve it?• If so, buy it• If not

– Does your enterprise allow open source?– If so use it

» Beware of licence implications– Only after evaluating and discounting alternatives should you

consider writing your own.

Page 31: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

31

Case Study #3

• Anti-Pattern: Code that plays together stays together

Page 32: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

32

Symptoms

• Let’s imagine a “Car” object• What properties should it have?– Make– Model– Colour

• What behaviour should it have?– None!– It’s an inanimate object!

• A “Car” will have things done to it by “actors”.

Page 33: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

33

What Is The Problem?

1 2 3 4 5 6 7 8 9 10

Difficulty in adding Features Over Time

Page 34: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

34

Example of Class Pollution

Credit: Phil Winstanley (http://weblogs.asp.net/Plip/)

Page 35: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

35

Why Is This Technical Debt?

• Borrow time now, repay later• Borrowed time now– Simpler object graph

• Repay later in cost of adding functionality.

Page 36: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

36

Concrete Example

• Online provider wants to be first to market• Ships service with monolithic object graph• Effort required to add new features grows• Development slows to a crawl• Management demand a fix.

Page 37: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

37

Quantifying the Technical Debt

• 1 monthly iteration to fix this debt• Resources deployed:– 5 X Developers– 1 X lead developer– 2 X testers

• Apply these figures to our formula and:• Cost of technical debt: 44,800 Euros.

Page 38: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

38

Fixing The Technical Debt

• Understand that– Monolithic object graph has a limited lifespan– Prefer separation of concerns– If first to market is important• Understand the value of the technical debt accrued• Decide when the debt will be paid off• Decide if commercial gain outweighs cost of debt

• Refactoring tools can reduce “interest” on debt.

Page 39: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

39

Case Study #4

• The Anti-Pattern: Sensitive Tests

Page 40: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

40

Symptoms

• Test which are sensitive to– Context– Interface– Data

• Pass in one iteration• Fail in the next due to changes.

Page 41: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

41

Why Is This Technical Debt?

• Borrow time now, repay later• Borrowed time in the form of easy to write

tests• Repay later in form of fixing sensitive tests.

Page 42: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

42

Concrete Example

• Tester testing code which uses data from development database

• Developer adds new functionality– Shape of the database changes– Values in the database change

• Previously passing tests fail• Tests rewritten using current dev. database.

Page 43: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

43

Quantifying the Technical Debt

• Take previous 283 defects per project• Assume 10% of tests for those defects are

data dependant• Assume it takes tester 30 minutes to fix each

test• 28 * 0.5 = 14 hours• Apply those figures to our formula and:• Technical debt = 392 Euros.

Page 44: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

44

Fixing The Technical Debt

• Test must use independent data– Don’t run tests against development data– Either• Have a dedicated test database• Or it may be possible to mock data access • Or have the set up code for each test or suite of tests

generate the data it requires and drop it during the tear down code.

Page 45: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

45

How Do We Spot Technical Debt?

Page 46: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

46

We Are Used to Charting Progress

1 2 3 4 5 6 7 8 9 1011121314151617181920212223242526272829300

102030405060708090

100

Burndown Graph

Days

% T

ask

Rem

aini

ng

Page 47: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

47

Time Budget Failures Are Obvious

1 2 3 4 5 6 7 8 9 1011121314151617181920212223242526272829300

102030405060708090

100

Burndown Graph

Days

% T

ask

Rem

aini

ng

Page 48: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

48

Effect #1 – Loss of Productivity

0 2 4 6 8 10 12 140

2

4

6

8

10

12

14

16

Items of Functionality per Iteration

Iteration Number

Item

s of

Fun

ction

ality

Com

plet

ed

Page 49: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

49

Effect #1 – Loss of Productivity

0 2 4 6 8 10 12 140

2

4

6

8

10

12

14

Items of Functionality per Iteration

Iteration Number

Item

s of

Fun

ction

ality

Com

plet

ed

Page 50: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

50

Effect #2 – Increase In Testing

0 2 4 6 8 10 12 140

2

4

6

8

10

12

14

16

Tests per Item of Functionality

Iteration Number

# Te

sts

per I

tem

of F

uncti

onal

ity

Page 51: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

51

Effect #2 – Increase In Testing

0 2 4 6 8 10 12 1402468

1012141618

Tests per Item of Functionality

Iteration Number

# Te

sts

per I

tem

of F

uncti

onal

ity

Page 52: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

52

Effect #3 – Decrease In Morale

0 2 4 6 8 10 12 140

1

2

3

4

5

Team Morale

Iteration Number

Ave

rage

Tea

m M

oral

e

Page 53: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

53

Effect #3 – Decrease In Morale

0 2 4 6 8 10 12 140

1

2

3

4

5

Team Morale

Iteration Number

Ave

rage

Tea

m M

oral

e

Page 54: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

54

Summary

• In this presentation you learned:– What technical debt is– That it is important to manage technical debt– Some common anti-patterns and how to fix them– Metrics to spot hidden technical debt– How to quantify technical debt.

Page 55: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

55

Take Away

• If you only take away one thing– Know that technical debt is• the silent killer that stalks all projects

– Don’t let it kill your projects!

Page 56: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

56

Further Reading

• http://c2.com/cgi/wiki?WardExplainsDebtMetaphor• http://c2.com/cgi/wiki?TechnicalDebt• http://blogs.construx.com/blogs/stevemcc/

archive/2007/11/01/technical-debt-2.aspx• http://www.martinfowler.com/bliki/TechnicalDebt.html

Page 57: Credit Crunch Code Paying Back the Technical Debt By Gary Short 1

57

Questions?

• There wasn’t time for my question• Where can I contact you?– [email protected]– www.garyshort.org– On Twitter as @garyshort.