Beberapa waktu yang lalu saya mendapatkan email dari Patrick Smacchia, saya agak terkejut juga karena saya pernah membaca beberapa tulisan di blog beliau yang sangat menarik terutama mengenai software metric. Patrick menawarkan saya untuk mencoba product Visual NDepend professional edition, saya segera mencari informasi tentang product tersebut dan merasa tertarik untuk mencoba (walaupun sebelumnya saya tidak pernah mendalami software metrics). Thanks kepada Patrick yang sudah memberikan license Visual NDepend sehingga saya dapat mencoba product keren ini.
Jika membaca dari website Visual NDepend, tujuan dari software ini:
NDepend is a tool that simplifies managing a complex .NET code base. Architects and developers can analyze code structure, specify design rules, plan massive refactoring, do effective code reviews and master evolution by comparing different versions of the code.
The result is better communication, improved quality, easier maintenance and faster development.
Untuk mencoba Visual Ndepend versi trial / open source di http://www.ndepend.com/NDependDownload.aspx
Scott Hanselman juga pernah membuat podcast tentang software metric di Hanselminutes Podcast 163 - Software Metrics with Patrick Smacchia
Saya sebenarnya juga masih bingung dengan konsep-konsep sofware metrics karena hampir tidak pernah melakukan analisis terhadap kode yang saya buat :) boro-boro melakukan software metrics, TDD aja ga sempat :), tapi dengan Visual Ndepend maka kita dapat melakukan analisis code metrics dengan cepat dan otomatis.
Visual Ndepend memiliki ukuran yang relatif kecil (hanya 17Mb) setelah di ekstrak, untuk menjalankannya klik file VisualNDepend.exe
Maka akan muncul tampilan halaman utama sebagai berikut :
![clip_image001[5] clip_image001[5]](http://www2.ukdw.ac.id/kuliah/si/erickblog/VisualNDependToolskerenuntukCodeMetrics_84E/clip_image0015_thumb.png)
Klik menu 'analyze' dan pilih file assembly yang akan dianalisis. Sebagai contoh saya memilih file .dll dan .exe dari aplikasi sample yang saya buat
![clip_image001[7] clip_image001[7]](http://www2.ukdw.ac.id/kuliah/si/erickblog/VisualNDependToolskerenuntukCodeMetrics_84E/clip_image0017_thumb.png)
Maka otomatis Visual Ndepend akan menggenerate file .html yang berisi analisis code metrics-nya
![clip_image001[9] clip_image001[9]](http://www2.ukdw.ac.id/kuliah/si/erickblog/VisualNDependToolskerenuntukCodeMetrics_84E/clip_image0019_thumb.png)
Jika anda ingin mempelajari lebih jauh tentang software metric anda dapat membaca di : http://www.ndepend.com/Metrics.aspx
Adapun isi jenis2 code metrics yang disupport oleh Visual Ndepend :
- 12 metrics on application:
NbLinesOfCode, NbLinesOfComment, PercentageComment, NbILInstructions, NbAssemblies, NbNamespaces, NbTypes, NbMethods, NbFields, PercentageCoverage, NbLinesOfCodeCovered, NbLinesOfCodeNotCovered - 18 metrics on assemblies:
NbLinesOfCode, NbLinesOfComment, PercentageComment, NbILInstructions, NbNamespaces, NbTypes, NbMethods, NbFields, Assembly level, Afferent coupling (Ca), Efferent coupling (Ce), Relational Cohesion(H), Instability (I), Abstractness (A), Distance from main sequence (D), PercentageCoverage, NbLinesOfCodeCovered, NbLinesOfCodeNotCovered - 13 metrics on namespaces:
NbLinesOfCode, NbLinesOfComment, PercentageComment, NbILInstructions, NbTypes, NbMethods, NbFields, Namespace level, Afferent coupling at namespace level (NamespaceCa), Efferent coupling at namespace level (NamespaceCe), PercentageCoverage, NbLinesOfCodeCovered, NbLinesOfCodeNotCovered - 22 metrics on types:
NbLinesOfCode, NbLinesOfComment, PercentageComment, NbILInstructions, NbMethods, NbFields, NbInterfacesImplemented, Type level, Type rank, Afferent coupling at type level (TypeCa), Efferent coupling at type level (TypeCe), Lack of Cohesion Of Methods (LCOM), Lack of Cohesion Of Methods Henderson-Sellers (LCOM HS), Code Source Cyclomatic Complexity, IL Cyclomatic Complexity (ILCC), Size of instance, Association Between Class (ABC) Number of Children (NOC), Depth of Inheritance Tree (DIT), PercentageCoverage, NbLinesOfCodeCovered, NbLinesOfCodeNotCovered - 19 metrics on methods:
NbLinesOfCode, NbLinesOfComment, PercentageComment, NbILInstructions, Method level, Method rank, Afferent coupling at method level (MethodCa), Efferent coupling at method level (MethodCe), Code Source Cyclomatic Complexity, IL Cyclomatic Complexity (ILCC), IL Nesting Depth, NbParameters, NbVariables, NbOverloads, PercentageCoverage, NbLinesOfCodeCovered, NbLinesOfCodeNotCovered, PercentageBranchCoverage - 2 metrics on fields:
Size of instance, Afferent coupling at field level (FieldCa)
Hasil output dari analisis code metric:
![clip_image001[11] clip_image001[11]](http://www2.ukdw.ac.id/kuliah/si/erickblog/VisualNDependToolskerenuntukCodeMetrics_84E/clip_image00111_thumb.png)
Pada analisis application metrics anda dapat melihat jumlah dari IL Instruction, line of code, dll dari aplikasi yang anda buat
Visual Ndepend juga dapat menampilkan grafik yang berisi ukuran assembly beserta method2 nya (terus terang saya belum jelas untuk membacanya karena tampilannya cukup aneh hehe )
![clip_image001[13] clip_image001[13]](http://www2.ukdw.ac.id/kuliah/si/erickblog/VisualNDependToolskerenuntukCodeMetrics_84E/clip_image00113_thumb.png)
Visual Ndepend juga menampilkan Assemblies Dependencies Diagram
![clip_image001[15] clip_image001[15]](http://www2.ukdw.ac.id/kuliah/si/erickblog/VisualNDependToolskerenuntukCodeMetrics_84E/clip_image00115_thumb.png)
Tampilan warning akan muncul jika code anda dirasa tidak efisien
![clip_image001[17] clip_image001[17]](http://www2.ukdw.ac.id/kuliah/si/erickblog/VisualNDependToolskerenuntukCodeMetrics_84E/clip_image00117_thumb.png)
Seperti pada contoh diatas anda dapat menquery lines of code dari method pada aplikasi anda, disana ditampilkan warning karena lines of code pada method dirasa terlalu besar sehingga harus dipecah kedalam method-method yang lebih kecil.
Saya baru sempat sedikit mencoba tools yang sangat 'cool' ini, dan saya masih harus banyak membaca konsep software metric untuk dapat lebih memahami grafik-grafik dan analisis hasil output dari Visual Ndepend.