Top 8 ChatGPT Prompts For Programmers with Examples
Published: 2023-06-18 09:21:56

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dux7tg16ncb0xfamlx9a.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1jic4e3cp11dkdn4p7hx.png)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1xbats1buddwnd7270k0.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k9r77joqra1byhtqj2yb.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o37mjk35ebwookenzhns.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xpg2xhzd2vfj4tk86kbb.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6nw9nz4k2sorz4g2qldt.png)


# 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4mqx9wrpokemp5mxu2cm.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xskyksw99jjb12u1mvu6.png)


# 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0n2xea7onk5q3sns8egd.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/itzsq23a2kuzgh996w4p.png)


# 4. Coding Completion

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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/05rcf8fbr351x56tu5dl.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cmiqtj7ssomq1wqn7bc1.png)


# 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i451pfe1xvrd8lwqe400.png)

# 6. Documentation

you also can request ChatGPT to document your method or class

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nud6xnwp2lov0q1nyopi.png)


# 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qv6islc9bzbr0xsxykhn.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7khrus8fmnqjeq9dscd7.png)


# 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fvqaa252ht6nqrfnzci3.png)