Content deleted Content added
Replace HTML markup tags with Wiki markup tags |
Add: redlink for Maurice Howard Halstead |
||
(24 intermediate revisions by 20 users not shown) | |||
Line 1:
{{short description|Software maintainability index}}
'''Halstead complexity measures''' are [[software metric]]s introduced by [[Maurice Halstead|Maurice Howard Halstead]] in 1977<ref name="Elements of Software Science">{{cite book |author=Halstead, Maurice H. |title=Elements of Software Science |publisher=Elsevier North-Holland, Inc. |___location=Amsterdam |year=1977 |isbn=0-444-00205-7}}</ref> as part of his treatise on establishing an empirical science of software development.
Halstead made the observation that metrics of the software should reflect the implementation or expression of algorithms in different languages, but be independent of their execution on a specific platform.
These metrics are therefore computed statically from the code.
Line 9:
== Calculation ==
For a given problem,
* <math>\,\eta_1</math> = the number of distinct operators
* <math>\,\eta_2</math> = the number of distinct operands
Line 18:
* Program vocabulary: <math>\eta = \eta_1 + \eta_2 \,</math>
* Program length: <math>N = N_1 + N_2 \,</math>
* Calculated estimated program length: <math>\hat{N} = \eta_1 \log_2 \eta_1 + \eta_2 \log_2 \eta_2 </math>
* Volume: <math>V = N \times \log_2 \eta </math>
* Difficulty : <math>D = { \eta_1 \over 2 } \times { N_2 \over \eta_2 } </math>
Line 29:
Halstead's delivered bugs (B) is an estimate for the number of errors in the implementation.
*Number of delivered bugs : <math>B = {E^{2 \over 3} \over 3000}</math> or, more recently, <math>B = {V \over 3000}</math> is accepted.<ref
== Example ==
<syntaxhighlight lang="c">
main()
{
}
</syntaxhighlight>
The
<code>main</code>, <code>()</code>, <code>{}</code>, <code>int</code>, <code>scanf</code>,
<code>&</code>, <code>=</code>, <code>+</code>, <code>/</code>, <code>printf</code>,
The
<code>a</code>, <code>b</code>, <code>c</code>, <code>avg</code>, <code>"%d %d %d"</code>, <code>3</code>, <code>"avg = %d"</code>
Line 74:
* [https://github.com/dborowiec/commentedCodeDetector Script computing Halstead Metrics and using them for commented code detection]
* [http://pic.dhe.ibm.com/infocenter/rtrthelp/v8r0m0/index.jsp?topic=%2Fcom.ibm.rational.testrt.studio.doc%2Ftopics%2Fcsmhalstead.htm IBM]
* [https://www.vcalc.com/wiki/halstead%20software%20complexity Calculator for computing Halstead metrics]
[[Category:Software metrics]]
|