Framework Decision Helper Source Code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Framework Decision Helper</title>
</head>
<body>
<h2>Framework Decision Helper</h2>
<?php
$fieldCnt = 0;
if ($_REQUEST['usage']) {
$a = (int) $_REQUEST['usage'];
$fieldCnt++;
} else {
$mode = "a";
}
if ($_REQUEST['developerWagePerHour']) {
$b = (int) $_REQUEST['developerWagePerHour'];
$fieldCnt++;
} else {
$mode = "b";
}
if ($_REQUEST['frameworkBootingTime']) {
$c = (int) $_REQUEST['frameworkBootingTime'];
$fieldCnt++;
} else {
$mode = "c";
}
if ($_REQUEST['appLifetime']) {
$d = (int) $_REQUEST['appLifetime'];
$fieldCnt++;
} else {
$mode = "d";
}
if ($_REQUEST['changePeriod']) {
$e = (int) $_REQUEST['changePeriod'];
$fieldCnt++;
} else {
$mode = "e";
}
if ($_REQUEST['creationSaveTime']) {
$f = (int) $_REQUEST['creationSaveTime'];
$fieldCnt++;
} else {
$mode = "f";
}
if ($_REQUEST['changeSaveTime']) {
$g = (int) $_REQUEST['changeSaveTime'];
$fieldCnt++;
} else {
$mode = "g";
}
if ($fieldCnt !== 6) {
$message = "please fill out 6 fields, not " . $fieldCnt;
} else {
// a*365*d*c*100/b = f*60*60*1000+g*52/e*d*60*60*1000
switch ($mode) {
case "a":
$a = ($f * 3600000 + $g * 52 / $e * $d * 3600000) / (365 * $d * $c * 100 / $b);
$message = "use the framework with less than " . number_format($a, 0, '.', '') . " requests per day";
break;
case "b":
$b = $a * 365 * $d * $c *100 / (3600000 + $g * 52 / $e * $d * 3600000);
$message = "use the framework if the developer time is worth more than " . number_format($b, 0, '.', '') . " percent as much as the time of the user.";
break;
case "c":
$c = ($f * 3600000 + $g * 52 / $e * $d * 3600000) / ($a * 365 * $d * 100 / $b);
$message = "use the framework if it boots in less than " . number_format($c,0,'.','') . " milliseconds.";
break;
case "d":
$d = $f * 3600000 / ($a * 365 * $c * 100 / $b - $g * 52 / $e * 3600000);
$message = "use the framework if the script lives longer than " . number_format($d, 0, '.', '') . " years.";
break;
case "e":
$e = 52 * $g * $d * 3600000 / ($a * 365 * $d * $c * 100/$b - $f * 3600000);
$message = "use the framework if you change the script every " . number_format($e, 0, '.', '') . " weeks or earlier.";
break;
case "f":
$f = ($a * 365 * $d * $c * 100 / $b - $g * 52/$e * $d * 3600000) / 3600000;
$message = "use the framework if it save more than " . number_format($f,0,'.','') . " hours during development.";
break;
case "g":
$g = ($a * 365 * $d * $c * 100 / $b - $f * 3600000) / ($d * 3600000 * 52 / $e);
$message = "use the framework if you save more than " . number_format($g,0,'.','') . " hours each time you change the script.";
break;
}
}
echo $message;
?>
</body>
</html>