🔥ChatGPT-4编程神器?掌握这些提示词,开发者效率翻倍!💼💻

学会提问 2年前 (2023) lida
48 0 0

文章主题:代码生成, 代码完成, bug检测

666ChatGPT办公新姿势,助力做AI时代先行者!

🌟🚀ChatGPT-4编程神器!🔥💻专为开发者打造超实用提示词集,解锁代码魔力!🔍🔥代码生成?一发即达!ChatGPT-4帮你一键写出高效代码段,提升开发效率翻倍!💼🔍bug检测?不在话下!AI助手秒辨问题所在,修复bug就像玩游戏!🎮👀代码审查?专家级水准!ChatGPT-4提供精准建议,让代码更规范、更安全!🛡️📚API文档?轻松生成!只需简单指令,专业文档瞬间呈现,告别繁琐工作!📝无论你是前端开发者、后端程序员还是全栈工程师,这些提示词都将是你手中的得力工具。立即拥抱ChatGPT-4的智能编程世界,让开发变得更简单、更有趣!🚀🌟记得,保护知识产权,合理使用哦!👨‍💻👩‍💻

代码生成 Code Generation

生成样板代码,指明编程语言,类、模块、组件、方法名称等等 Generate a boilerplate [language] code for a [class/module/component] named [name] with the following functionality: [functionality description].创建方法,指明输入输出参数 Create a [language] function to perform [operation] on [data structure] with the following inputs: [input variables] and expected output: [output description].创建类、包,指明包含的方法、属性名称等 Generate a [language] class for a [domain] application that includes methods for [methods list] and properties [properties list].指定设计模式,创建最佳代码实现 Based on the [design pattern], create a code snippet in [language] that demonstrates its implementation for a [use case].

例子:

Generate a boilerplate Python code for a shopping cart module named “ShoppingCart” with the following functionality:

– A constructor that initializes an empty list to store cart items.

– A method called “add_item” that takes in an item object and adds it to the cart.

– A method called “remove_item” that takes in an item object and removes it from the cart if it exists.

– A method called “get_items” that returns the list of items in the cart.

– A method called “get_total” that calculates and returns the total price of all items in the cart.

Bug检查

检查潜在bug Identify any potential bugs in the following [language] code snippet: [code snippet].指定错误类型 Analyze the given [language] code and suggest improvements to prevent [error type]: [code snippet].内存泄漏 Find any memory leaks in the following [language] code and suggest fixes: [code snippet].

例子: Identify any potential bugs in the following Python code snippet:

def calculate_sum(num_list):
sum = 0
for i in range(len(num_list)):
sum += num_list[i]
return sum

Code审查

是否符合最佳实践 Review the following [language] code for best practices and suggest improvements: [code snippet].代码风格、规范化 Analyze the given [language] code for adherence to [coding style guidelines]: [code snippet].模块化、可维护性方面的检查Evaluate the modularity and maintainability of the given [language] code: [code snippet].

例子: Review the following Python code for best practices and suggest improvements:

def multiply_list(lst):
result = 1
for num in lst:
result *= num
return result

文档生成

例子: Generate API documentation for the following JavaScript code:

/**
* Returns the sum of two numbers.
* @param {number} a – The first number to add.
* @param {number} b – The second number to add.
* @returns {number} The sum of a and b.
*/

function sum(a, b) {
return a + b;
}

查询优化

例子: Optimize the following SQL query for better performance:

SELECT *
FROM orders
WHERE order_date BETWEEN 2022-01-01 AND 2022-12-31
ORDER BY order_date DESC
LIMIT 100;

UI设计

例子: Generate a UI mockup for a mobile application that focuses on managing personal finances.

自动化测试

Generate test cases for the following [language] function based on the input parameters and expected output: [function signature].Create a test script for the given [language] code that covers [unit/integration/system] testing: [code snippet].Generate test data for the following [language] function that tests various edge cases: [function signature].Design a testing strategy for a [web/mobile] app that includes [unit, integration, system, and/or performance] testing.

例子: Generate test cases for the following Python function based on the input parameters and expected output:

def divide(a: float, b: float) -> float:
if b == 0:
raise ZeroDivisionError(division by zero)
return a / b

代码重构

Suggest refactoring improvements for the following [language] code to enhance readability and maintainability: [code snippet].Identify opportunities to apply [design pattern] in the given [language] code: [code snippet].Optimize the following [language] code for better performance: [code snippet].

例子: Optimize the following Python code for better performance:

def find_max(numbers):
max_num = numbers[0]
for num in numbers:
if num > max_num:
max_num = num
return max_num

Design pattern suggestions

Based on the given [language] code, recommend a suitable design pattern to improve its structure: [code snippet].Identify opportunities to apply the [design pattern] in the following [language] codebase: [repository URL or codebase description].Suggest an alternative design pattern for the given [language] code that may provide additional benefits: [code snippet].

Example: Based on the given Python code, recommend a suitable design pattern to improve its structure:

代码转换

从一种编程语言转化为另一种编程语言 Translate the following [source language] code to [target language]: [code snippet].Convert the given [source language] class or module to [target language] while preserving its functionality and structure: [code snippet].Migrate the following [source language] code that uses [library or framework] to [target language] with a similar library or framework: [code snippet].

例子: Translate the following Python code to JavaScript:

def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n-1)

代码可视化

生成UML图 Generate a UML diagram for the following [language] code: [code snippet].流程图 Create a flowchart or visual representation of the given [language] algorithm: [algorithm or pseudocode].依赖图 Visualize the call graph or dependencies of the following [language] code: [code snippet].

例子: Generate a UML diagram for the following Java code:

public abstract class Vehicle {
private String model;

public Vehicle(String model) {
this.model = model;
}

public String getModel() {
return model;
}

public abstract void start();

public abstract void stop();
}

public class Car extends Vehicle {
public Car(String model) {
super(model);
}
@Override
public void start() {
System.out.println(“Starting car engine”);
}
@Override
public void stop() {
System.out.println(“Stopping car engine”);
}
}
public class Motorcycle extends Vehicle {
public Motorcycle(String model) {
super(model);
}
@Override
public void start() {
System.out.println(“Starting motorcycle engine”);
}
@Override
public void stop() {
System.out.println(“Stopping motorcycle engine”);
}
}

数据可视化

数据集可视化 Generate a bar chart that represents the following data: [data or dataset description].按时间序列可视化 Create a line chart that visualizes the trend in the following time series data: [data or dataset description].热力图 Design a heatmap that represents the correlation between the following variables: [variable list].

🔥ChatGPT-4编程神器?掌握这些提示词,开发者效率翻倍!💼💻

🔥ChatGPT-4编程神器?掌握这些提示词,开发者效率翻倍!💼💻

AI时代,掌握AI大模型第一手资讯!AI时代不落人后!

免费ChatGPT问答,办公、写作、生活好得力助手!

扫码右边公众号,驾驭AI生产力!

相关文章