ChatGPT for programmers

ChatGPT for programmers

Many people say chatGPT will take away the job of programmers. Believe that's not going to happen. Let's take chatGPT as your assistant rather than a competitor.

The art of questioning

The first and foremost trait here is the art of questioning. I have seen people complaining that they do not get correct answers. Be aware that chatGPT is an AI-based chatbot. The information we receive is only as accurate and helpful as the question we ask. Ensure that questions are concise, clear and specific so that AI can understand what we want.

Here are some good & not so good examples

  • Not so good - What is the price of iPhone?
  • Good - What is the price of iPhone 13 mini 128 GB variant in Pune?
  • Not so good - Recommend me a good restaurant you idiot.
  • Good - Can you recommend me a good vegetarian restaurant in Andheri which has outdoor seating?
  • Not so good - What are the top news stories today?
  • Good - What are the top news stories in the technology section of Times Of India today?


How ChatGPT can help you in programming?

Now that you have understood it from a basic view, let's understand it from a programmer's point of view.

ChatGPT can help you to write and refactor your code, can suggest comments for methods, write unit tests for you and a lot more.

You can ask it to write code for you, the only condition is that your questions should be framed correctly.

Not so a good question

Create an employee class.        

ChatGPT response

No alt text provided for this image
When asked ChatGPT to create an employee class

Specific Question

Can you create a class Employee with 4 properties 
EmployeeId, Name, ContactNumber and DateOfJoining. 
The class should also have 3 methods to create, update and delete employees. 
The class should be CLS-compliant and must have an XML summary for 
all the methods.        

Chat GPT Response

Now you might have noticed that with a very specific command, we are able to exactly get what we want. Imagine if you had to write this code on your own, you must have at least spent 15 minutes with possibly a few typos in the XML summary.

Question 3 - Asking to write test cases

Can you write 5 test cases for following code
public int Divide(int a, int b)
{
    return a / b;
}?        

ChatpGPT response

No alt text provided for this image
Asking chatgpt to write test cases


Summary

We've seen that AI chatbots can help us to write, understand, and refactor code. They can help us to populate the comments and XML summaries.

There is Visual Studio extension is available too which I will explain in my next topic. For now: Adios!!!

Questions must be:
* Clear
* Concise
* Specific
* Provide sufficient inforamtion

ChatGPT capabilities:
* Can explain complex code in simple terms
* Can suggest performance bottlenecks
* Can write test cases
* Can optimize your code
* Rewrite code in another language        
Shanmuga Sundaram S

Senior Java Consultant

1 年

Thanks a lot, this was very useful

回复
Abbhayy Kumar Gupta

BPO Client Servicing Strategic Leader??Call Center Training Operation Expert??Content Design & Development Specialist

1 年

Thanks for sharing Shantanu Shukla

Ravi Garg

Transform Your Financial Future Today! I empower salaried professionals with personalized retirement plans, proven equity strategies, and expert mutual fund guidance. Book your 1-on-1 session now, Live Your Dream life!

1 年

Grt insight on how to use ChatGPT Shantanu Shukla

回复
Naveen Sukamanchi - Digitial Transformation - Automation

Assisting businesses with their digital footprint improvements through Digital transformation | Process reengineering | Automation | Artificial intelligence , to help them achieve their business goals

1 年

very useful article

Pranab Prakash ?

?? Pioneering Digital Transformation & IT Automation | ?? AI & Data Science Advocate | Catalyzing 30%+ Business Growth with Agile Leadership & Program Management | ?? PgMP?, PMP?, SAFe?, ITIL?

1 年

Thanks for the post. Please note that while ChatGPT can be helpful for programmers, it is important to verify the accuracy of the information and suggestions provided before implementing them in your projects. Always consult official documentation and other trusted sources to ensure best practices are being followed.

要查看或添加评论,请登录

社区洞察

其他会员也浏览了