Halstead metric
The Halstead Metric is a software metric introduced by Maurice Howard Halstead in 1977 . It belongs to the static, analyzing methods of measuring the complexity of software .
In this case, the system component is not actively executed (as in the dynamic process), but information about the test item is collected using analytical means.
calculation
The Halstead metric uses the assumption that executable program parts are made up of operators and operands. Defining what the operators and operands are to be considered is one of the tasks before using a Halstead metric. Typically, e.g. B. Consider variables and constants as operands; Keywords , logical and comparison operators, etc. as operators.
The following basic dimensions are then formed for each program:
- Number of different operators ( ) and operands ( ) used, together the vocabulary size .
- Total number of operators ( ) and operands ( ) used, together the implementation length .
The sizes Halstead length ( ) and Halstead volume ( ) are then calculated from this:
Various key figures can be calculated from the basic parameters:
- Difficulty writing or understanding a program, e.g. B. in a code review :
- Effort:
- Implementation time: seconds
The Halstead metric is easy to determine and calculate, can be automated and can be used for all programming languages. The key figures usually agree very well with the values actually measured. The disadvantage is that it only affects individual functions and only measures lexical / textual complexity.
See also
literature
- Maurice Howard Halstead: Elements of software science . Elsevier, New York et al. a. 1977, ISBN 0-444-00205-7 (Operating and programming systems series; 2).
- Harry Sneed , Richard Seidl , Manfred Baumgartner: Software in numbers - the measurement of applications . 1st edition. Carl Hanser Verlag , 2010, ISBN 978-3-446-42175-2 .
Web links
- Measurement of Halstead metrics
- Calculation of McCabe and Halstead metrics using a sample project (PDF file; 737 kB)