DEV Community

harry
harry

Posted on

Top 8 ChatGPT Prompts For Programmers with Examples

As we know, ChatGPT is very popular and powerful this year, it has many functions in addition to answering simple questions like writing essay, summarizing text, building resume, writing Excel formulas, translation and so on. so what benefits would ChatGPT give programmers? today I would like to introduce top 8 prompts which can help programmer ease their work.

1. Coding Generation

As a programmer, sometime we would like a tool to generate a code example for our requirement so that we don't need to code it from scratch. below is an example to ask chatgpt to provide us a algorithm with python language to predict the number of user based on date.

Image description

Image description

you also can ask it to generate it with specify python package like tensorflow

Image description

Image description

To request chatgpt to do it with java programming language for comparison. to be suprised, we really have a way to do it with java

Image description

Image description

Image description

2. Debugging Code

Before commiting code into our feature branch, we also can request chatgpt to check whether our code has problem or not.

Also, if you are experincing some exception and you have located the suspected snippet code which causes it, in this case , you can let chatgpt to debug your code.

Image description

Image description

3. Refactor Code or Clean Code

After you finished coding, you might find that your code is ugly(not clean) and you want to refactor your code so that your code reviewer can provide you approval.

Image description

Image description

4. Coding Completion

you might only make the beginning code in certain method and you want ChatGPT to complete it.

Image description

Image description

5. Generating Comments

you probably find that you didn't add comments in your code after you done code to implement JIRA. you can add comments yourself, but with ChatGPT you can request it to add it and then you review it.

Image description

6. Documentation

you also can request ChatGPT to document your method or class

Image description

7. Writing Test Cases

currently you might write test cases by your own or generate basic test cases by some tool. with Chatgpt, you can let it to generate a liitle bit complex test cases automatically. after that, you can adjust it a little bit.

Image description

Image description

8. Explain Coding Techniques and Concepts

I am sure that you don't know all techinques and concepts. you might use google to explore it. now with ChatGPT, you can check it.

Image description

Top comments (0)