Since late 2022, ChatGPT has gradually entered many aspects of our daily lives, automated or simplified processes and enhanced productivity. Without even consciously noticing it, I caught myself using ChatGPT with an increasing frequency for accomplishing simple (or harder) coding tasks I perform during a normal working day.
Here are the 5 ways I use it to make the most out of it as a professional software developer.
1. Write docstrings
ChatGPT is AMAZINGLY good at writing concise and informative docstrings for functions and classes. You can simply copy a function and as it to write the docstrings. The model is capable of understanding what the function does, many times even on a higher / more abstract level and document it as well. Sometimes, the format may differ a bit but you can always adjust it to what you need with an additional prompt. So no more time spent writing docstrings for functions and classes.
Refactoring is a very broad term containing various tasks that mαy need to be performed in code that has been written long in the past or it is not well implemented or documented. Parts of refactoring may be renaming variables and declarations with more appropriate names, split large functions and classes to separate smaller ones, reimplementing a part of the code with less lines etc. Thankfully, using the appropriate prompts ChatGPT is capable of accurately performing the majority of these tasks. From declarations renaming to splitting function into smaller and more discrete parts, ChatGPT will help you write cleaner and more straight-forward code that is maintainable and readable by you or fellow developers.
3. Write unit tests
ChatGPT is able to write unit tests saving you lot of time during the development lifecycle of any project that involves coding. A tasks that many times is much needed but may be extremely mundane, boring and time-consuming at the same time. By pasting a function and asking ChatGPT to write the unit tests, the model will perform the task and ensure that various aspects of the function are tested. If the function is complex, additional prompts may be needed to cover all cases.