I will focus on local variables in OO languages ββ(Java, C #, C ++). I can come up with a series of measures regarding the scope of a local variable.
Local Variable Area Size
- the number of operators available for the local variable. This should not be too large, as it indicates a method too long. However, counting a method operator may be more appropriate for this.
Available value of a local variable
- the number of available local variables for each method operator. It should not be more than 3, as it makes the choice which local variable is used in the expression more difficult.
Local density using variables
represents the percentage of statements accessing a local variable and statements where a local variable is available. Low values ββindicate that the method is not very coherent.
Coherent modification of local variable calculations
- the number of modifications of local variables within the same block. This indicates that several local variables belong to each other. Therefore, they must create their own object, thereby increasing consistency.
Spacetracker
source share