Качество кода. NDepend

  • Published on
    15-Jun-2015

  • View
    448

  • Download
    5

Embed Size (px)

DESCRIPTION

NDepend

Transcript

. NDepend

1 / NDepend . . , , , Ndepend .2 ?

? . , , - . ? , . , . , .3

, . user friendly . . . .

. . . . . . , . 4 (, , ..) (, )(, ) , . , , () ?, (iron triangle, project management triangle) , : , (, ). Quality, , , . , (scope), (time/schedule) (cost/budget) , . . , , , , , , . , , (). , , , . , ( - ) . ? , deadlock .

, . : , , . , : ( ), . ( , ) , . , , , : , (), . . . (!) . , . : . -, ( ). -, , . -, , , , . , , . , (): 9 1 . , . , .. , , . . ( ). , : , . , , . , , . . : , , -, . , ? , :) , IT 20-25% , 45-50% , , ( ). , . , , , , , . , , change requests management, , . - , . 5 (, , ..) (, )(, ) , http://www.intuit.ru/department/se/msd/4/3.html 6 ?

, , , . , , , - :). , , . , , , , , . , , , , ., , " ", " " .. , ().8 ? XP (eXtreme Programming)Code reviewProject management, methodology, Utilities: StyleCop, FxCop, Code AnalysisRequirements-TDD, Defensive programming styleOOP/OOD, principles

?

Code review ,Unit-tests, TDD/BDD

-

OOP/OOD, principles, Programming style

ode Review

StyleCop, FxCop, Code Analysis, Ndepend review .

. CI (build process)

= (e.g. Cowboy coding)

: , , . - . . 13Extreme programming code review- (TDD)YAGNI, ,

XP? XP: coding, testing, listening, designing14

. -, TDD- .

DD .

Unit-tests: , . ,

TDD:

16

Defensive programming

(asserts) (code contracts)

-

. .18

, , .

(Technical debt). - , , .. , , . , () , , , . , - . , , . , , . / , . , , . Jeff Atwood.19, (), . - - , . - , . - . , , . , , :) , , , , , , . .

=== , , . 20 / SOLID GRASP

KISS = Keep it simpleDRY = Dont repeat yourselfYAGNI = You aint gonna need it

http://msug.vn.ua/Posts/Details/4221 SOLID: Single resposibility, Open-close principle ( , ), Liskov substitution, Interface segregation, Dependency injection

GRASP: Information Expert, Creator, Controller, Low Coupling, High Cohesion, Pure Fabrication, Indirection (), Protected Variations, Polymorphism

21 , :Lines of codeNumber of classesInheritance depth Maintainability indexCyclomatic index

NDepend. Dependency graph

NDepend. Dependency graph

Ndepend. Dependency matrix

Ndepend. Metrics view

CQL Query Explorer

NDepend. CQLSQL (code base), -

SELECT TOP 10 METHODS ORDER BY NbLinesOfCode DESC

SELECT METHODS WHERE NbLinesOfCode > 10

SELECT FIELDS WHERE HasAttribute "System.ThreadStaticAttribute"

CouplingEfferent coupling (Ce): , , Afferent coupling (Ca): , Instability (I)Instability (I): (Ce) , . I = Ce / (Ce + Ca)I=0 , .I=1 , Abstractness (A)Abstractness (A): , .

A=0 A=1 Relational Cohesion (H)Relational Cohesion (H): , :H = (R + 1) / N, R = , N =

, .

, . 1.5 H 4.0 Coupling, Cohesion, Abstractness and Instability metrics on example

= , , I , N , , Lack of cohesion (LCOM) SRP , . (cohesive).

.

, LCOM > 0.8 . , -

Cyclomatic Complexity (CC) :if, while, for, foreach, case, default, continue, goto, &&, ||, catch, ? : (ternary operator), ?? (nonnull operator)

: else, do, switch, try, using, throw, finally, return, object creation, method call, field access

CC > 15 , CC > 30 ( )Distance from main sequence:zone of pain and zone of uselessnessMain sequence NDepend,A + I = 1, D main sequence, 0 D 1

D > 0.7 -

, , . .

C Msughttp://msug.vn.ua/Posts/Details/4199 - NDependhttp://msug.vn.ua/Posts/Details/4221 - GRASPNDependhttp://www.ndepend.com/ http://www.ndepend.com/GettingStarted.aspx NDependhttp://www.hanselman.com/blog/content/binary/NDepend%20metrics%20placemats%201.1.pdf http://ndepend.com/Metrics.aspx http://merle-amber.blogspot.com/ http://blog.byndyu.ru 38 :)

39