Models of Thumb Abstract
We explore a scalable programmer-in-the-loop approach to improving Java source code quality, which focuses on “routine” code quality concerns. We specifically explore overspecific variable declarations, for which we introduce a novel analysis, and ignored exceptions (for which the analysis is straightforward).
In order to assess feasibility of our approach, we have developed several style checkers for Java programs and applied them to a 2MLOC corpus of deployed production code. Our analysis of the corpus indicates that fully 20% of Java exceptions are ignored and 60% of those lack an explanatory comment. In addition, 4% of all variable declarations overspecify the variable type (i.e., fail to abstract to an appropriate level of the inheritance hierarchy).
We consider issues of adoptability and the user experience. For example, we introduce an annotation scheme for documenting programmer intent with respect to violation of these style rules. We also describe a capability in our prototype tool to offer repairs to the programmer when quality issues are raised. This is a factor in the design of the analyses.
We call the overall approach “models of thumb” because it is designed to assist in identifying and addressing code quality criteria usually expressed in the literature as informal rules of thumb. A “model of thumb” includes a precise characterization of the particular quality attribute, scalable analyses for compliance, and rules for suggesting repairs to violation.