Вы находитесь на странице: 1из 51

Measuring Agile Process

With Ruby
RubyConf Ukraine 2010

Hubert Łępicki
hubert.lepick@amberbit.com
Me
Hubert Łępicki
hubert.lepicki@amberbit.com

hubert.lepicki@gmail.com

github.com/hubertlepicki

twitter.com/hubertlepicki

hubertlepicki.com
http://amberbit.com
Agile
Hot topic
http://agilemanifesto.org
Individuals and interactions over
processes and tools

Working software over comprehensive


documentation

Customer collaboration over contract


negotiation

Responding to change over following a


plan
no process and tools?

no documentation?

no contract negotiation?

no plan?
WRONG
There are contracts
simple

flexible

service over product


it "should have documentation"

it "should be readable"

it "can be in form of tests"

it "can be in form of code"


there must be a plan
The process
well defined by methodology

eXtreme Programming

Scrum

Kanban

Crystal
What do they have in
common?
iterations

incremental development

defined roles in project


What are the differences?
eXtreme Programming: engineering
practices

Scrum: project management

Kanban: fast delivery of features


Why do we (Ruby
programmers) use Agile
methodologies?
they fit object oriented programming

they have simple rules

they can reduce/control chaos


Despite trying to
implement agile
methodologies, sometimes
things go bad.
how bad?
I used to work on a
project we were going to
finish in October 2007
we finished in October

2008

that bad

(that was BEFORE we started AmberBit


;))
What is to blame?
bad programmers

bad management

wrong implementation of agile


methodologies
(http://www.halfarsedagilemanifesto.org/)
If a project fails, you want to know what
went wrong

During development, you want to know


if things are likely to go wrong
You need to measure the
process
yeah, but how?
Let's thing what can go
wrong during the project
poor implementation of agile
methodologies

communication problems

software quality degrades

project doesn't meet budget, scope or


time
and many more
What to measure - a few
examples
project size

team velocity

project progress

value of one story point in time


number of passing/failing tests

code complexity

code coverage

test to code ratio


Tools
Your issue tracker

Ruby

CI builds
Project size
rake stats
+----------------------+-------+-------+---------+-----
| Name | Lines | LOC | Classes | Meth
+----------------------+-------+-------+---------+-----
| Controllers | 519 | 401 | 14 |
| Helpers | 43 | 35 | 0 |
| Models | 658 | 496 | 16 |
| Libraries | 119 | 89 | 4 |
| Model specs | 854 | 718 | 0 |
| View specs | 5 | 4 | 0 |
| Helper specs | 18 | 15 | 0 |
| Acceptance specs | 371 | 299 | 0 |
+----------------------+-------+-------+---------+-----
| Total | 2587 | 2057 | 34 |
+----------------------+-------+-------+---------+-----
Code LOC: 1021 Test LOC: 1036 Code to Test Ra
# Quick and dirty way to get number of lin
# in source code of your app
Dir.glob("app/**/*.rb").collect do |f|
`cat #{f} | wc -l`.to_i
end.sum
# Better, get only number of lines of code
Dir.glob("app/**/*.rb").collect do |f|
File.readlines(f).select{
|l| !(l =~ /^\s*($|#)/)
}.size
end.sum
Test results
When using RSpec, write your own
formatter

or hook into BaseFormatter:


Monkeypatching RSpec
class Spec::Core::Formatters::BaseFormatter
alias_method :old_dump_summary,
:dump_summary

def dump_summary(*args)
old_dump_summary(*args)

Faraday.get("http://mydomain.com/"+
"passed=#{args[1] - args[2]}
"&failed=#{args[2]}")
end
end
Code complexity
why bother?

it can be a measure of technical debt

debt removed earlier is easier to manage


Static code analysis with
Ruby
Flog - http://ruby.sadi.st/Flog.html

Saikuro - http://saikuro.rubyforge.org/

^^ these are 1.8-only ^^

metric_abc - http://github.com/
hubertlepicki/metric_abc
metric_abc in action
$ metric_abc user.rb
user.rb > User > update_flagging_history: 18
user.rb > User > initialize: 16
user.rb > User > vote_on: 13
user.rb > User > generate_readable_id: 9
user.rb > User > thumbnail_url: 9
user.rb > User > visit_ids: 8
user.rb > User > already_voted?: 8
user.rb > User > suggested_locations: 8
...
ok, now what?
calculate metrics

store metrics in database

visualize metric changes over time


examples
how to plot?
Gnuplot.open do |gp|
Gnuplot::Plot.new( gp ) do |plot|
x = ProjectSize.all.collect{ |m| m.day}
y = ProjectSize.all.collect{ |m| m.val}
plot.title "Project Size"
plot.ylabel "LOCs"
plot.xlabel "days"

plot.data << Gnuplot::DataSet.new([x,y])


ds.with = "linespoints"
ds.notitle
end
end
end
Final notes
do not trust metrics, treat them as
inteligence reports

analyse periodically

analyse failed projects

take actios to fix processes in your


teams
Thank you!