Halstead complexity measures

The Halstead metric is a 1977 presented by Maurice Howard Halstead software metrics. It belongs to the static analysis procedures to the complexity of measuring software.

Here, the system is not running an active component (as in the dynamic process ), but also specific information about the test object is collected with the analytical means.

Calculation

The Halstead metric uses here the assumption that executable program parts are composed of operators and operands. The definition of what are to be considered operators and operands, it is one of the tasks before using a Halstead metric. Typically, such as variables and constants are considered as operands; Keywords, logical and comparison operators, etc. as operators.

The following basic measurements that are then formed for each program:

  • Number of different operators used () and operand (), collectively the vocabulary size.
  • Number of operators used in total () and operand (), along the length of implementation.

From this, the sizes Halstead length () and Halstead volume () are calculated:

From the basic variables, one can calculate various indicators:

  • Difficulty to write a program or to understand, for example, in a code review:
  • Effort:
  • Implementation time: seconds

The Halstead metric is easy to identify and compute, automated and used for all programming languages. The figures usually agree very well with actual measured values ​​. The disadvantage is that it only affects individual functions and exclusively lexical / textual complexity measures.

371109
de