01 /*
02 * Created on Aug 29, 2007
03 */
04 package com.x8ing.mc.bp.develop;
05
06 import java.util.Iterator;
07 import java.util.List;
08
09 import com.x8ing.lsm4j.Condition;
10 import com.x8ing.lsm4j.state.ProcessableState;
11 import com.x8ing.mc.bp.AbstractBusinessAction;
12 import com.x8ing.mc.bp.BalanceAccount;
13 import com.x8ing.mc.bp.Bug;
14 import com.x8ing.mc.bp.BusinessContext;
15 import com.x8ing.mc.distribution.RandomDistribution;
16 import com.x8ing.mc.distribution.RandomDistributionGauss;
17
18 /**
19 * @author Patrick Heusser
20 */
21 public class AnalyzeCostLossAction extends AbstractBusinessAction {
22
23 private RandomDistributionGauss bugProcessValueLoss = null;
24
25 private RandomDistribution bugFixingCosts = null;
26
27 /**
28 * @see com.x8ing.mc.bp.AbstractBusinessAction#execute(com.x8ing.lsm4j.state.ProcessableState,
29 * com.x8ing.mc.bp.BusinessContext, com.x8ing.lsm4j.Condition, java.util.List)
30 */
31 public void execute(ProcessableState currentState, BusinessContext businessContext, Condition previousCondition,
32 List lastVisitedStatesHistory) {
33
34 // mark that we are start doing something
35 businessContext.setDevelopProcessBusy(true);
36
37 // TODO: FIX BUG HERE!!!!!!!!!!!
38
39 // adjust process loss probability for having process improvement
40 // TODO: document this in thesis work! there are much more sophisticated ways to
41 // approximate the bug finding curve.
42 int rangeMin = 0;
43 int rangeMax = (int) ((businessContext.getConfiguration().getSoftwareInitialNoncCnformityCost() - businessContext
44 .calculateTotalProcessLossOfAllBugsEverFound()) / 12);
45
46 if (rangeMin >= rangeMax) {
47 rangeMax = rangeMin + 1;
48 }
49
50 if (rangeMax < 3) {
51 // software is almost perfect
52 businessContext.setNoMoreDiscoveringOfBugs(true);
53 addLogBookEntry("no more analyzing and discovering of bugs possible");
54
55 }
56
57 bugProcessValueLoss.init(rangeMin, rangeMax, 2);
58
59 // find recently added bugs and evaluate them
60 for (Iterator bugIt = businessContext.getBugs().getBugsWithStateNew().iterator(); bugIt.hasNext();) {
61
62 Bug recentlyDiscoveredBug = (Bug) bugIt.next();
63
64 double processLossDueToBug = Math.round(bugProcessValueLoss.getNextRandomNumber());
65 double bugFixingCost = Math.round(bugFixingCosts.getNextRandomNumber());
66
67 // set numbers that we discovered
68 recentlyDiscoveredBug.setEstimatedCostToFixBug(bugFixingCost);
69 recentlyDiscoveredBug.setNegativImpactOnBusinessProcess(processLossDueToBug);
70
71 addBalanceSheetTransaction("Analyzing of cost loss", -businessContext.getConfiguration()
72 .getCostActionAnalyzeCostLoss(), BalanceAccount.BUG_ANALYZING);
73
74 addLogBookEntry("Analyzing cost loss. Bug (id=" + recentlyDiscoveredBug.getBugID() + ") decreases process value by "
75 + processLossDueToBug);
76 }
77
78 }
79
80 protected void lazyInit() {
81
82 bugProcessValueLoss = new RandomDistributionGauss(-1, 1, 1);
83 bugFixingCosts = new RandomDistributionGauss(businessContext.getConfiguration().getDistributionBugFixingCostMin(),
84 businessContext.getConfiguration().getDistributionBugFixingCostMax(), businessContext.getConfiguration()
85 .getDistributionBugFixingCostStdDev());
86
87 }
88
89 }
|