class Seecalc::CoD

# Cost of Delay (CoD)

## Rules

**Shortest Job First**. When the cost of delays are the same, do the smallest feature first.

**High Delay Cost First**. When effort is the same, do the high delay cost feature first.

**Weighted Shortest Job First (WSJF)**. When job effort and delay costs differ, prioritize by dividing the job’s cost of delay by its effort.

## Calculations

CoD is critical to our decision-making criteria—is, in turn, an aggregation of three attributes of a feature, each of which can be estimated fairly readily, when compared to other features. They are **user value**, **time value**, and **risk reduction value**.

Usage: “`ruby

require 'seecalc'
features = Seecalc::CoD.prioritize do
  item title: 'Feature A', effort: 4, user: 4, time: 9, risk: 8
  item title: 'Feature B', effort: 6, user: 8, time: 4, risk: 3
  item title: 'Feature C', effort: 5, user: 6, time: 6, risk: 6
  item title: 'Feature D', effort: 9, user: 5, time: 5, risk: 1
  item title: 'Feature E', effort: 9, user: 7, time: 5, risk: 1
  item title: 'Feature F', effort: 8, user: 7, time: 5, risk: 1
end
pp features #sorted features

“`

end

Attributes

items[R]

Public Class Methods

new() click to toggle source
# File lib/seecalc/cod.rb, line 48
def initialize
  @items = []
end
prioritize(&block) click to toggle source
# File lib/seecalc/cod.rb, line 41
def self.prioritize(&block)
  pr = new
  pr.instance_eval(&block) if block_given?
  pr.sort
  pr
end

Public Instance Methods

item(title:, effort:, user:, time:, risk:) click to toggle source

TODO chek if item with same title esist

# File lib/seecalc/cod.rb, line 53
def item(title:, effort:, user:, time:, risk:)
  msg = '%s must be an integer in range 1..10'
  raise ArgumentError, msg % 'User value' unless (1..10).cover?(user)
  raise ArgumentError, msg % 'Time value' unless (1..10).cover?(time)
  raise ArgumentError, msg % 'Risk reduction' unless (1..10).cover?(risk)

  @items << { title: title, effort: effort, user: user,
              time: time, risk: risk, cod: user + time + risk }
end
sort() click to toggle source
# File lib/seecalc/cod.rb, line 63
def sort
  @items.sort!{ |x, y| sort_cod(x, y) }
end

Private Instance Methods

sort_cod(x, y) click to toggle source
# File lib/seecalc/cod.rb, line 69
def sort_cod(x, y)
  # Shortest Job First. When the cost of delays are the same, do the smallest feature first.
  return x[:effort] <=> y[:effort] if x[:cod] == y[:cod]

  # High Delay Cost First. When effort is the same, do the high delay cost feature first.
  return -1 * (x[:cod] <=> y[:cod]) if x[:effort] == y[:effort]

  # Weighted Shortest Job First (WSJF). When job effort and delay costs differ, prioritize by dividing the job’s cost of delay by its effort.
  x[:wsjf] = (x[:cod].to_f / x[:effort]).round(2) unless x[:wsjf]
  y[:wsjf] = (y[:cod].to_f / y[:effort]).round(2) unless y[:wsjf]
  -1 * (x[:wsjf] <=> y[:wsjf])
end