Вы находитесь на странице: 1из 14

c 


 

   
u 
 20.07.2009



7 50 ,
,
.





, "
" [1].
,
.
,
. PVS-Studio
,
64-
.
.
, ,
-
, - , -
, ,
, .

, ,
,
.
, ,
,
, .
, , ,
, , ,
, . , ,
, ..
.

A   






, (
). (SLOC).
. - ,

, ,
.
. - .
,
[2].
SLOC :
,
,
( ,
, ),
(, ),
, (, ),
.
(F).
n
FU = SIGN (N.U / NU - 0,1), N.U - i- , NU i- .
: F = FU. [2]
, ,
[3]. :
n1 - , , ( ),
n2 - ( ),
N1 - ,
N2 - ,
n1' - ,
n2' - .
, :
n=n1+n2 - ,

N=N1+N2 - ,
n'=n1'+n2' - ,
N'= n1*log(n1) + n2*log(n2) - (
N N' 10%)
V=N*logn - ,
V'=N'*logn' - , n* - .
L=V'/V - , L=1
L'= (2 n2)/ (n1*N2) - ,
,
E =V/(L')2 - ,
D=1/ L' - ,
y' = V/ D2 -
I=V/D - ,

E=N' * log(n/L) - ,

,

.
, , .

. , ,
,
, ,
.


  

, ,
,
.
,
.
.
, ,
, ,
,

. :
, [4].
, ,
( -) [4].
V(G)=e - n + 2p, e - , n - , p -
.
, .
, .
, . . , ""
, , , ,
, , .
V(G) .
p=1,
:
V(G)=e - n + 2.
, .
, ,
,
( - , ).
. .
( ) [V(G),V(G)+h],
h , n- h=n-1.
, .
- - .
( , ).
.

, .
,
.
.
. - m+1, m - .
- 2. ,
-.
,
- , .
.
,
. ,
. ,
, , ,

( ), ,
- .
.

, ,
.
(SCOPE) -
.
(SCORT)
, .
SCORT .
- .

,
. N(G) = v *(G) + Pi , v *(G) , , V(G),
: CASE n , n
- 1 .
i - i- .
" ".
" " ,
, .
, " ".
,
.
- .
,
(, ).
,
.
.
.
G -
.
,
- .
: , <=1; ,
>=2.
, .

, 1,
, 0. G
, .
:
S0=1-(v-1)/Sa,
S0 - , Sa -
, v - .
,
.

} 
  
 



- .
:
.
, -, 4
:
1. P - ,
2. M - , ,
3. C - , (
),
4. T - ("") .
,
.
:
Q = a1*P + a2*M + a3*C + a4*T,
a1, a2, a3, a4 - .

. , ,
3, C, .
: a1=1, a2=2,
a4=0.5. T 0, ""
, .
:
Q = P + 2M + 3C + 0.5T


. - , ,
. , , n ,
, n-1. .
, - ,
.
"- " (p,r), p- ,
r.
r " - ":
. r p , r
p.
Aup , Up
, Pup -
.

Rup = Aup/Pup.

. , ,
"" - ,
, .
.
: A B
, :
1. ( )
2. , (
)
3. , .
:
D , D,
D.
I - :
I = length * (fan_in * fan_out)2
:
length - ( - ,
, , LOC ..)
fan_in - ,

fan_out - ,


.
-
. :
J = W * R + W * RW + RW *R + RW * (RW - 1)
W - , ;
R - ;
RW - , .
- . ,
- ,
.
:
,
; ,
.
R(i) ,
i (
, ,
,
). V(i) ,
i. i- :
DF(i)=(DEF(v)), j=i...||V(i)||
DEF(v) - v R(i), ||V(i)|| V(i).


  
 



, ,
,
( ,
- ,
).
,
.
- [5].
, :

.
.
(, , )
,
.
.
.
[6].
,
. . :
-
.
().
-
() .
- - ,
.
,
. () , ,
-, , ,
; -, ,
.
- .
, , ..
.
- ,
.
- ,
, , .
- .
- - -,
, - .
- ,
.
, - [7],
, ,
, ,
.

- -.
:
1. i t C(i)
: C(i) = (D(i) * J(i))/n.
D(i) - , i. J(i) -
i, n - .
2. , ,
M(P) M(P) = fp * X(P) + gp * Y(P)
fp gp - , ,
P, X(P) - P,
Y(P) - P .
3. MP
:
MP = (M(P)) P - .
, ,
, .
, ,
,
, .
, - [8].
M=fU*logpU, fU - i- , pU .
, ,
, , ,
, .

u 
 
 





-
, - .
.
.

[9].
. ,
, .
.
.
:

.
, , ,
. ,
.
.
. ,
,
.
.
,
, .
:
1. Ca : . ,
.
2. Ce: . ,
.
3. I: : I = Ce / (Ca+Ce). [0,1].
I = 0 .
I = 1 .
, ( ,
) :
A: : A = nA / nAll.
nA - ____.
nAll - o____.
[0,1].
0 = ,
1 = .
,
. ,
I+A=1, ,
.
.
2 :
: D=|(A+I-1)/sqrt(2)|
: Dn=|A+I-2|

,
, .
- [10].
, ..
WMC (Weighted methods per class), : WMC=cU,
i=1...n, cU - i- , ( ..
), , WMC=n.
DIT (Depth of Inheritance tree) - (
-), , ,
, ,
.
NOC (Number of children) - (), ,
.
CBO (Coupling between object classes) - ,
, . ,
, CBO
.
RFC (Response for a class) - RFC=|RS|, RS - ,
, ,
. RS=(({M}({RU}), i=1...n , M - ,
RU - , i- . RFC
. RFC, .
LCOM (Lack of cohesion in Methods) - .
C n M1, M2, ... ,Mn, {I1},{I2},...,{In} -
, . P - ,
; Q - , .
LCOM=|P|-|Q|. ,
,
.


 
 
- , ,
. ,
: ,
, , ,
,
, .
, ..
.

3  


, .

. .
:
H_M = (M + R1 * M(M1) + ... + Rn * M(Mn)/(1 + R1 + ... + Rn)
M - , Mi - , Ri -
, M(Mi) - .
M(Mi) Ri
.
, : ,
SLOC, .
"", "" "".
, ,
. :
(, , , ) (a, b, c, d).
( , , /, )
(x, y, z, p).
,
- .

 


, , .

, , ,
,
. , - ,
,
- , .

! "
#
1.Y : "
". http://www.viva64.com/blog/ru/2009/06/09/166/
2.Y ., " IBM Rational ClearCase"
http://www.viva64.com/go.php?url=241
3.Y . .
. . .
http://www.viva64.com/go.php?url=243
4.Y T.J. McCabe, "A complexity measure," IEEE Transactions on Software Engineering, vol. SE-2, no.
4, pp. 308-320, December, 1976.

5.Y .., " ", - 2000, 210


.
6.Y .. . : - .
" XXI ". .: , 1997. 320 .
7.Y .., "
", , - 1998
8.Y Curtis R. Cook, "Information Theory Metric for Assembly Language"
9.Y .. " " http://www.viva64.com/go.php?url=242
10.Y Shyam R. Chidamber, Chris F. Kemerer, "A Metrics Suite for Object Oriented Design", 1994