👨💻
Writing code comments
Writing code comments is an essential aspect of software development that helps improve the readability, maintainability, and quality of the codebase. However, it can be a tedious and time-consuming task for developers, especially when they have to document complex codebases or work on tight deadlines. That's where ChatGPT comes in handy. ChatGPT is an AI-powered virtual assistant that can help developers write code comments quickly and efficiently. With its natural language processing capabilities and vast knowledge base, ChatGPT can provide developers with suggestions for writing effective code comments.
Prompts
"Could you utilize appropriate technical terminology and programming concepts to compose a comprehensive code commentary for the identified [FUNCTION/CLASS/METHOD]? The commentary should elucidate the functionality, input/output parameters, and exception handling mechanisms within a limit of [AMOUNT] sentences. Additionally, provide a brief explanation on how the code interacts with other modules if applicable. Ensure to include any dependencies or preconditions for effective operation of the [FUNCTION/CLASS/METHOD]."
"Can you add comments to this [EXISTING CODEBASE/LEGACY CODE/THIRD-PARTY LIBRARY] that was written by [ANOTHER DEVELOPER], to make it easier to [FUNCTION] for future users? [INSERT CODEBASE]"
"I need to document my code for [PROJECT NAME]. Could you write comments for [FUNCTIONS/CLASSES/FILES] in the [LANGUAGE] programming language? Make sure to include details about [PREFERRED CHARACTERISTIC]. [INSERT CODEBASE]"
"As part of code testing, I need clear documentation of the [FUNCTIONS/CLASSES/FILES] for [PROJECT NAME]. Please write comments that provide insight into code [CHARACTERISTIC]. [INSERT CODEBASE]"
"Can you revise the [STATUS] code comments for [PROJECT NAME], to reflect the latest changes? [INSERT CODEBASE]"