Halstead complexity measures are software metrics introduced by Maurice Howard Halstead in 1977. These metrics are computed statically, without program execution.
First we need to compute the following numbers, given the program source code:
From these numbers, five measures can be calculated:
The difficulty measure is related to the difficulty of the program to write or understand, e.g. when doing code review.