Content area
In this thesis, we present two approaches: one for generating header comments and the other for generating unit tests for test-driven development (TDD). These approaches share some similarities, including the use of LLMs and templating, but are used to achieve different goals. Documentation comments are essential for maintainability, yet they are often missing or outdated. This is true not only for programs in general-purpose languages, but also for artifacts in other languages often found in software projects such as scripts or configuration files. To address this problem, we present an approach that uses Large Language Models (LLMs) to generate header comments (aka, ‘block comments’ or ‘doc-strings’) for elements of different languages in different documentation formats. Given a file in some language and a description of elements in the file to be documented and the documentation format to be used, the approach generates header comments for all undocumented elements in the file that is guaranteed to conform to the documentation format. We describe a prototype implementation and its integration into an industrial development pipeline. Feedback from our industrial partner, an LLM-as-judge evaluation, and the participants of a user study involving a broad range of languages indicates that the approach is viable, able to produce sufficiently high-quality documentation in general, and holds potential for improving industrial documentation practices across different programming languages and teams.
TDD is a process that has been shown to reduce software defects, but is not always adopted in industrial software. TDD can also reduce the cost of debugging software by finding code defects earlier and can contribute to better software design. We also present an approach that uses generative AI to generate unit tests to facilitate TDD. Given a user goal, the approach generates formalized requirements in the form of a goal model, which is then used to generate unit tests in a test folder. We describe a current prototype implementation and show the results of our approach.