Skip to content

Instantly share code, notes, and snippets.

@eel3
Last active February 20, 2020 13:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eel3/78b3cf7ce7395a97dcb5aac21baf2fb0 to your computer and use it in GitHub Desktop.
Save eel3/78b3cf7ce7395a97dcb5aac21baf2fb0 to your computer and use it in GitHub Desktop.
COCOMO 81 Time-Delivery calculation module (based on JUAS software metrics report)
<#
.SYNOPSIS
Calculate an optimul project work period from a man months.
.INPUTS
None.
.OUTPUTS
None.
.EXAMPLE
C:\PS> powershell -ExecutionPolicy RemoteSigned
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
PS C:\PS> . .\workperiod.ps1
PS C:\PS> $wp = [WorkPeriod]::new()
PS C:\PS> $wp.Period(12)
5.72357121276666
PS C:\PS> $wp.MinPeriod(12)
4.29267840957499
PS C:\PS> $wp.HeadCount(12)
2.09659311536712
PS C:\PS> $wp.MaxHeadCount(12)
2.79545748715616
PS C:\PS> $wp = [WorkPeriod]::new([Factor]::JUAS_2016)
PS C:\PS> 12, 24, 36 | %{ $wp.Period($_) }
5.95251406127733
7.49969776559852
8.58501084712603
#>
Set-StrictMode -Version Latest
enum Factor {
Boehm_1981
JUAS_2007
JUAS_2016
}
class WorkPeriod {
hidden [double] $_WorkPeriodFactor
hidden [double] $_MinPeriodRatio
hidden [void] _Init([Factor] $factor) {
switch ($factor) {
Boehm_1981 {
$this._WorkPeriodFactor = 2.5
$this._MinPeriodRatio = 0.75
}
JUAS_2007 {
$this._WorkPeriodFactor = 2.4
$this._MinPeriodRatio = 0.70
}
JUAS_2016 {
$this._WorkPeriodFactor = 2.6
$this._MinPeriodRatio = 0.70
}
default {
throw "unknown argument: $factor"
}
}
}
hidden [double] _CubeRoot([double] $n) {
return [Math]::Pow($n, 1.0 / 3.0)
}
WorkPeriod() {
$this._Init([Factor]::Boehm_1981)
}
WorkPeriod([Factor] $factor) {
$this._Init($factor)
}
[double] Period([double] $ManMonth) {
if ($ManMonth -lt 1) {
throw 'argument must be greater than or equal to 1'
}
return $this._WorkPeriodFactor * $this._CubeRoot($ManMonth)
}
[double] MinPeriod([double] $ManMonth) {
if ($ManMonth -lt 1) {
throw 'argument must be greater than or equal to 1'
}
return $this.Period($ManMonth) * $this._MinPeriodRatio
}
[double] HeadCount([double] $ManMonth) {
if ($ManMonth -lt 1) {
throw 'argument must be greater than or equal to 1'
}
return $ManMonth / $this.Period($ManMonth)
}
[double] MaxHeadCount([double] $ManMonth) {
if ($ManMonth -lt 1) {
throw 'argument must be greater than or equal to 1'
}
return $ManMonth / $this.MinPeriod($ManMonth)
}
}
# frozen_string_literal: true
# encoding: utf-8
# -*- coding: utf-8-unix -*-
# vim:fileencoding=utf-8:ff=unix
#
# workperiod.rb - Calculate an optimul project work period from a man months.
class WorkPeriod
module Constants
# B. W. Boehm, Softwore Engineering Economics
FACTOR_BOEHM_1981 = 0
# JUAS software metrics report 2007
FACTOR_JUAS_2007 = 1
# JUAS software metrics report 2016
FACTOR_JUAS_2016 = 2
end
include Constants
def initialize(factor=FACTOR_BOEHM_1981)
case factor
when FACTOR_BOEHM_1981
@WORK_PERIOD_FACTOR = 2.5
@MIN_PERIOD_RATIO = 0.75
when FACTOR_JUAS_2007
@WORK_PERIOD_FACTOR = 2.4
@MIN_PERIOD_RATIO = 0.70
when FACTOR_JUAS_2016
@WORK_PERIOD_FACTOR = 2.6
@MIN_PERIOD_RATIO = 0.70
else
raise ArgumentError, "unknown argument: #{factor}"
end
end
# The optimul work period for a man_month size project.
def period(man_month)
raise ArgumentError, 'argument must be greater than or equal to 1' unless man_month >= 1
@WORK_PERIOD_FACTOR * cbrt(man_month)
end
# The minimum work period for a man_month size project.
def min_period(man_month)
raise ArgumentError, 'argument must be greater than or equal to 1' unless man_month >= 1
period(man_month) * @MIN_PERIOD_RATIO
end
# The optimul headcount for a man_month size project.
def headcount(man_month)
raise ArgumentError, 'argument must be greater than or equal to 1' unless man_month >= 1
man_month / period(man_month)
end
# The maximum headcount for a man_month size project.
def max_headcount(man_month)
raise ArgumentError, 'argument must be greater than or equal to 1' unless man_month >= 1
man_month / min_period(man_month)
end
private
# Cube root.
def cbrt(n)
n ** (1.0 / 3.0)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment