function Total_defects(f, verbose) { return \ defects(f,"requirements","r", verbose) + \ defects(f,"design", "d", verbose) + \ defects(f,"coding", "c", verbose) } function defects(f,what,area,verbose, introduced,percentRemoved) { introduced = defectsIntroduced1(f,what,area); percentRemoved = defectsRemovedRatio(f,what,area); if (verbose) print "f",f,"area",area,"intro",introduced, "p",percentRemoved, "removed",percentRemoved*introduced return percentRemoved*introduced; } function defectsIntroduced1(f,what,area) { return areaWeight(area)*Ksloc(f)^defectsB(area) * defectsIntroduced2(f,area); } BEGIN { string2pairs(_DefectsB,"r,10,d,20,c,30") } function areaWeight(area) { return _DefectsB[area] } function defectsB(area) { return 1} function defectsIntroduced2(f,area, temp,out,x,s,n) { out=1; for(x in Type) { s = cachedSlot(f,x) n = Factors2Numbers[s] temp = Coqual[area,n,x]; out *= temp } return out; } function defectsRemovedRatio(f,what,area, auto,review,tool) { auto = drf(f,"automated_analysis",area); review = drf(f,"peer_reviews",area); tool = drf(f,"execution_testing_and_tools",area); return (1 - auto)*(1 - review)*(1 - tool); } function drf(f,x,area,n, out) { n= Factors2Numbers[cachedSlot(f,x)] out= Drf[area, n,x] return out }