64
Deep SDLC Analysis

Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

Embed Size (px)

DESCRIPTION

Getting Ahead of Delivery Issues with Deep SDLC Analysis Donald Belcham .NET Conf UY 2014 http://netconf.uy

Citation preview

Page 1: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

Deep SDLC Analysis

Page 2: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

…a process for

planning, creating, testing, and deploying

an information system

http://en.wikipedia.org/wiki/Systems_development_life_cycle

Page 3: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham
Page 4: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

Cycles Decomposed

Requirements Code Testing

Deployments Defects

Page 5: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

Software

Page 6: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

Piecing it together

Get some requirements

Write some code

Commit code

Commit tests

Build and test

Manual testing/verification

Deploy

Page 7: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

We start “analyzing”

• Create a ‘backlog’

• Start estimating

• Work (sprint) planning

• Work assignments

• Estimated delivery date

• Burn down charts

Page 8: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

Don’t regularly “analyze”

• Code

• Automated tests

• Commit messages

• We could though

Page 9: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

Some “analysis” is done

• Build fail/pass

• Areas with high failed tests

• Defect churn

Page 10: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

Never “analyze”

• Deployments

Page 11: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

Analysis of analysis

• Inconsistent across SDLC areas

• Shallow

• Silo’d

• Very immature

• Missing software & data

Page 12: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

Inconsistency & Immaturity

• Data is silo’d by team function

• Don’t believe that areas are generating meaningful data

• Don’t know what to look at

• Don’t know how to look at the data

Page 13: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

Develo

per

Test

er

Develo

per

BA

Silos

Work

Ite

ms

Sourc

e C

ontr

ol

Conti

nuous

Inte

gra

tion

Test

Resu

lts

Deplo

ym

ents

Page 14: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

Meaningful DataExample: Source Control

Each check-in• Date-time

• Committer

• Comment

Metadata• Defect/Work Item #

• Files changed/added

• Contents changed/added

• Hash/commit #

• CR-LF, LF, <sigh>

Page 15: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

What to look at?Example: Work Items & Defects

• Defect age

• Open-to-close duration

• Frequency by application area

Page 16: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

How to look at the data?

• Don’t get too granular (i.e. individual defects)

• Look for trends• Change in code coverage

• Change in defect open time

• Change in estimate vs actual spread

Page 17: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

Getting More

• Stop silo-ing• By application

• By job description

• Tie the current pieces together

• Add the missing pieces

• Your biggest integration project yet

Page 18: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

Add value by adding nothing

• Start using existing analysis scripts• git_stats

• gitstats

• rewind

Page 19: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

rewind

• Git history analysis

• github.com/gilesbowkett/rewind

Page 20: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

rewind

Page 21: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

rewind

Page 22: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

Tying systems together

• Work Items & Defects

• Source Control

Page 23: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

Defects & Source Control

• Commit with defect/work item # in message

Page 24: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

Defects & Source Control

Page 25: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

Defects & Source Control

Query this:

- All defects that have been closed since <enter date>

- All commit hashes from returned defects

- Get all commit log entries for those hashes

- Get all modified/added files from those commits

== Modified files for this release

Page 26: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

Add a bit more

• Work Items & Defects

• Source Control

• Continuous Integration

Page 27: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

Some Continuous Integration

Page 28: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

CI information

• Get last pinned buildlocalhost/httpAuth/app/rest/builds/pinned:true,project:Umbraco,sinceBuild:127100

• Get changes included in the buildlocalhost/httpAuth/app/rest/changes?locator=build:(id:122960)

• Get files in the changeslocalhost/httpAuth/app/rest/changes/id:209381

Page 29: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

So……?

We know the files changed between pinned builds

We also know highly volatile files (remember rewind?)

Can we tell if we have high risk files in this release?

Well……sorta……

Page 30: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

Predicting code risk

• Multiple ways to try to accomplish this

• Active Analysis• You have unit tests right?

• You measure code coverage right?

• Static Analysis• Soooo many options

Page 31: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

rewind to rewind

• Shows past performance

• Strong indicator of the chance for change

• Weak indicator of the risk of the changes

Page 32: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

Automated Testing

• Some tests are good

• Some tests are not so good

• Tests against a class is a sign that you tried to care

• Not how much you cared

• Their existence is a mediocre indicator of risk

Page 33: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

Piecing it together

Get some requirements

Write some code

Commit code

Commit tests

Build and test

Manual testing/verification

Deploy

Page 34: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

Linking active analysis

• From CI we know the files that have changed

• CI will give us the names of all tests that were runlocalhost/httpAuth/app/rest/testOccurrences?locator=build:(id:122960)

• We can compare the lists to find files that changed that don’t have pattern matched test names

Customer.cs � CustomerTests.cs

InvoiceServices.cs � InvoiceServicesTests.cs

etc

Page 35: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

More active analysis

• Determining confidence in matched files/classes

• Code coverage• How many lines of code were executed by tests?

Page 36: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

Linking more active analysis

• From CI we know the files that have changed

• Code coverage will give us the %ages for each file/class

• We can compare the lists to find files that have low levels of coverage. This is the riskiest code under test.

Page 37: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

Better predictions

• Test existence and code coverage are, at best, mediocre indicators

• What if we have 100% coverage on 100% of the files?

• Deep static analysis

Page 38: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

Piecing it together

Get some requirements

Write some code

Commit code

Commit tests

Build and test

Manual testing/verification

Deploy

Page 39: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

Which metrics to use

• Afferent/Efferent Coupling• How many types do I rely on?

• How many types rely on me?

• Cyclomatic Complexity• How many different logic paths are there that can be executed?

• Instability (Efferent Coupling/Total Coupling)• How resilient is the object to change?

Page 40: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

Linking more static analysis

• From CI we know the files that have changed

• Can determine threshold crossing on different metrics

• Files found in both lists were changed, but probably weren’t easy to change

Page 41: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

So you’ve identified some files…

…that are at risk for having introduced defects, so how do you reduce/limit those yet to be found defects?

• Manual testing

It’ll catch some of the problems

Page 42: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

Different eyes see different things

• Will they test for nuanced technical constraints?

Developer enters a bar.

Orders a Βeer.

Orders a βeer.

Orders a Вeer.

Orders a Beer or Drink=Drink.

Orders a Beer; Update Drinks Set Price=0.00;

• Peer code reviews

Page 43: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

Piecing it together

Get some requirements

Write some code

Commit code

Commit tests

Build and test

Manual testing/verification

Deploy

Page 44: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

Triggering code reviews

1. CI compiles code

2. CI runs automated tests

3. CI runs code coverage

4. CI runs analysis scripts (rewind)

5. CI runs static analysis (nDepend)

6. Successful build triggers 2nd build project1. CI parses results from #3, #4, #5

2. Broken rules � call REST endpoint to create code review task

If it moves, automate it.

If it doesn’t move, kick it and then automate it.

Page 45: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

Deltas

•T in code coverage %

•T in LoC : commits

•T in coupling

•T in any metric you’ve decided to care about

• Probably not commit-to-commit

• Probably a release-to-release metric

Page 46: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

Deltas

• Systems need to be able to look at past data

• Many systems are limited in this fashion

• You’re probably going to have to write your own tool

• Make delta comparisons a build step like code coverage

Page 47: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

So we’ve done some cool stuff

• We can identify code that is at risk for change

• We can identify code that has changed

• We can identify how much risk there is in a release

• We can pre-empt some of that risk earlier in the cycle

Page 48: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

But we’ve only focused on the code

…and PMs, BAs and QAs *hate* it

when we focus solely on the code

Page 49: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

Nothing matters more than delivering

How long would it take for your organization to deploy a change that involves just one single line of code? Do you do this

on a repeatable, reliable basis?

Mary Poppendieck

How long does it take you to deliver feature/defect X?

Page 50: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

Measuring delivery/cycle time

Create defect/work item

Close defect/work item

Deliver the build to production

Page 51: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

Getting that info

• Deployment system ties to a package

• Package ties to a CI Build #

• CI Build can be used to determine included commits

• Each commit is linked to a defect tracking entry Time created

Time deployed

Cycle Time

Page 52: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

Performance

• Do you perf test?

• How often?

• Do you track changes in perf?

Page 53: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

Performance

• Part of a CI project • its own project since it will take time

• its own build agent to ensure isolation

• Make the output an artifact these can support deltas

• Changed files can focus analysis of perf output

• Quantifiable performance values• first run gives a baseline

• Supporting deliverables when deploying• Look! It didn’t get slower when we added that feature!

Page 54: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

How do you decide what to fix?

• Everything is always “High” or “Critical”

• Its always the finder’s baby/priority issue

• More users == more conflicting “High” issues

You fix it and find out “oh, we only use it once a year”

or “We use a different system, but thanks”

Page 55: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

Helping to prioritize

• Don’t take their word for it…do they *really* use it?

• System instrumentation• Log by feature relate them back to other systems

• Log each use able to count the number of uses

• Log when used determine frequency of use

Adding instrumentation should be easy. Use AOP. Be thorough.

Page 56: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

Prioritizing

Feature with defect but low use count might not be as critical to fix.

Feature used once a month might not have to be fixed and delivered tomorrow.

Page 57: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

So where does that leave you?

• Have some of these systems in place

• Generating a lot of data that you’re never using

• Probably have some gaps

Page 58: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

So where does that leave you?Get some requirements

Write some code

Commit code

Build and test

Manual testing/verification

Page 59: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

Easy winsGet some requirements

Write some code

Commit code

Build and test

Manual testing/verification

Code Reviews

Static Analysis

Page 60: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

More workGet some requirements

Write some code

Commit code

Commit tests

Build and test

Manual testing/verification

Deploy

Code Reviews

Code Coverage

Static Analysis

Page 61: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

Still more workGet some requirements

Write some code

Commit code

Commit tests

Build and test

Manual testing/verification

Deploy

Code Reviews

Code Coverage

Static Analysis

Performance Tests

Page 62: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

The most workGet some requirements

Write some code

Commit code

Commit tests

Build and test

Manual testing/verification

Deploy

Code Reviews

Code Coverage

Static Analysis

Performance Tests

Page 63: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

The gain

• Better planning

• More accurate estimates

• Less defects getting to testers

• Better understanding of the health of our software

Page 64: Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham

gracias

Donald Belcham@dbelcham

[email protected]