Learning to Generate Code Comments from Class Hierarchies
This addresses the need for better code comprehension and maintenance in software development, though it is incremental as it builds on prior comment generation methods.
The paper tackled the problem of automatically generating descriptive comments for overriding methods in code, proposing a novel framework that incorporates class hierarchy context and learned specificity representations, resulting in higher quality comments compared to existing techniques.
Descriptive code comments are essential for supporting code comprehension and maintenance. We propose the task of automatically generating comments for overriding methods. We formulate a novel framework which accommodates the unique contextual and linguistic reasoning that is required for performing this task. Our approach features: (1) incorporating context from the class hierarchy; (2) conditioning on learned, latent representations of specificity to generate comments that capture the more specialized behavior of the overriding method; and (3) unlikelihood training to discourage predictions which do not conform to invariant characteristics of the comment corresponding to the overridden method. Our experiments show that the proposed approach is able to generate comments for overriding methods of higher quality compared to prevailing comment generation techniques.