ChatGPT is going to change the world, and programmers also can't avoid this. The developer who uses AI will eventually replace the developer who does not use AI. Because AI will do your 8 hours of coding in just 2–3 hours.
As I have a 400K+ audience on Instagram, I decided to write a ChatGPT Guide for Software Developers that will help them use ChatGPT to become more productive and stay ahead of the competition.
So let's look at the top useful scenarios and prompts that will help you while coding.
Assume you're working on a new project or feature that requires you to write new code. You can cut more than half of your development time by doing the following:
Prompt to write a new code for new features and functionality
Prompt:
Act as a [Technology Name] developer. [Write a detailed description]
Example 1:
Act as a Python developer. Write code to read and print duplicate records from the provided CSV file.
Example 2:
Act as a JavaScript Developer, Write a program that checks the information on a form. Name and email are required, but address and age are not.
Example 3:
Act as a JavaScript Developer, Write a program that checks if a string contains a substring.
Prompt with technology stack and other details
Prompt:
Act as: [Enter your profile]
Technology stack: [Enter your technology stack]
Functionality: [Enter functionality]
Mandatory Fields: [Enter Fields]
Optional fields: [Enter Fields]
Task: [Write a task description]
Example 1:
Act as: Node.js Developer
Technology stack: Node.js, Express.js, MongoDB, Mongoose
Functionality: Newsletter
Mandatory Fields: Email
Optional fields: name
Task: Make an API that takes a name and an email address as inputs and sends back a success flag.
Example 2:
Act as: PHP Developer
Technology stack: Laravel 8, MySQL
Functionality: CAGR Calculation
Mandatory Fields: Amount and Years
Optional fields: NA
Task: Write a service that calculates CAGR.
Example 3:
Act as: PHP Developer
Technology stack: Laravel 8, MySQL
Functionality: Cron
Task: Write a cron that sends portfolio returns every day to users.
Prompt for fixing errors and bugs
Prompt :
Tell me how to debug the code to solve the given error.
Project: [Project name/description]
Technology Stack: [Technology Stack]
Error: [Explain the error]
Example:
Tell me how to debug the code to solve the given error.
Project: eCommerce
Technology Stack: JavaScript, Node.js, Express.js Stripe, MongoDB
Error: Orders get placed twice for Indian users.
Prompt: I am getting the error: [Insert your error message here] Tell me how to fix it.
Example: I am getting the error: Cannot get strings. key_one because property key_one is missing in undefined [1]. [1] strings?: [string_key: string]: string. Tell me how to fix this
Sometimes we get a logical error. We can fix the error by passing our code to ChatGPT.
Consider the following scenario: I am calculating CAGR and getting incorrect results. I will use ChatGPT to rectify this issue.
Prompt: I am working on the [Enter functionality], but my code is giving the wrong answer. Tell me what the error is. Here is my code. [Paste your code here]
Example:
I am working on the CAGR calculation functionality, but my code is giving the wrong answer. Tell me what the error is. Here is my code.
function calculateCAGR(startValue, endValue, years)
{
const cagr = (Math.pow(endValue / startValue) - 1) * 100;
return cagr.toFixed(2);
}
Don't Get Left Behind! Get this ChatGPT Guide to 10x Your Productivity and Become a New World Developer.
Click here to get Complete ChatGPT Guide for Software Developers and Stay Ahead of Competition
Prompt for Generating Dummy Data
I am building software to generate dummy data for my functionality.
Functionality: [Explain your functionality]
Generate data: [Enter columns or data you needed]
Data format: [Enter the data format]
Number of records: [Enter number of records]
Example: I am building software to generate dummy data for my functionality.
Functionality: Payment gateway integration
Generate data: user email, address, pin code
Data format: MySQL Queries Number of records: 20
Prompt for database tasks
After coding, database management takes a lot of time. You can write complex queries and make your work faster by using ChatGPT to write queries for your applications.
You can write plain SQL queries, MongoDB queries, and model queries using ChatGPT.
Let’s take examples
Prompt:
Write a [Language] Query
Tables: [Tables/collection list]
Requirement: [Mention your requirement]
Example 1:
Write a MySQL Query
Tables: users and orders
Requirement: It should give user details who placed highest order today
Example 2:
Write a MongoDB Query
Collections: users and orders
Requirement: It should return user information along with the total amount of previous purchases.
While working on new functionality, we need test data. We can use ChatGPT as a data feeder as follows:
Prompt:
Write a query to insert records in database
Database: [Enter database name]
Table/collection Name: [Enter table name]
Columns/fields:[Enter column names]
Number of records: [Enter record count]
You can use ChatGPT for various purposes, as follows:
- Writing a new code
- Getting quick solution for minor questions
- Fixing Errors
- Understanding the code
- Refactoring the code
- Database Management
- Code Review
- UI Development
- CSS Development
- Server Side Work
- Interview preparation
- Sending emails to client
- and many more