当前位置: 技术文章>> 盘点chatgpt针对软件开发工程师的20个最佳提示方法

文章标题:盘点chatgpt针对软件开发工程师的20个最佳提示方法
  • 文章分类: 后端
  • 20471 阅读

OpenAI的ChatGPT是一种使用自然语言处理(NLP)与人类用户进行对话的聊天机器人。它接受称为“提示”的文本输入,并且只以文本形式回复。使其脱颖而出的品质是,它可以根据给定的规范生成代码,并且对于任何类型的查询(无论是职业,教育,娱乐还是某个领域的太多技术或利基),都会给出非常描述性的答案。它还可以调试输入的代码,也可以充当解释器或编译器。

由于ChatGPT接受自然语言的提示,如果我们提供更描述性的提示,我们往往会获得更准确和精确的答案。这类似于提供更多详细信息,在地址中更准确地到达所需的位置。

现在问题来了,如何制定“提示”以获得更准确和精确的答案?因此,我们列出了面向软件开发人员的20个ChatGPT提示。

Explain

软件开发就是一边学习一边实现的过程。ChatGPT可以通过解释所需的概念来帮助我们。Explain提示可以用来理解概念、一段代码,或者让我们说算法的时间或空间复杂性。ChatGPT通过给出详细的答案来回答。

Explain how the {concept or function} works in {programming language}.

示例:

Explain how the below {programming language} code works {code snippet}

示例:

Explain the time and space complexity of the below code written in {programming language} {code snippet}

语法

软件开发人员使用各种各样的技术堆栈。因此,在选择新的堆栈时,很难记住每种语言和技术的语法。这就是ChatGPT的用武之地,它通过提供具有适当示例的编程语言元素的正确语法来提供帮助。

示例:

What is the correct syntax for a {statement or function} in {programming language}?

修复bug

在软件开发中,大量的时间都花在查找代码中的漏洞上。它不仅阻碍了个人的生产力,还延迟了代码的发货。使用这个提示,人们可以很容易地了解代码中的漏洞并获得调试方面的帮助。

示例:

How do I fix the following {programming language} code which {explain the functioning}? {code snippet}

最佳实践

了解行业最佳实践在编码时非常重要。这使得代码易于阅读,并在组织成长时有助于维护代码库。我们可以要求ChatGPT在为特定编程语言编写代码时遵循一组规则和建议。

示例:

Show me best practices for writing {concept or function} in {programming language}.

优化

建议始终编写最优化代码,因为这可以提高程序性能并帮助节省资源。优化可以是行数方面,也可以是空间和时间复杂度方面。我们可以使用ChatGPT来获取一段优化后的代码。

示例:

Optimize the following {programming language} code which {explain the functioning}: {code snippet}

示例:

Example – Optimisation in terms of number of lines of code

生成代码

我们还可以使用ChatGPT根据输入中提供的要求为我们编写一段代码。在这里,描述需求对于获得所需结果是至关重要的。

示例:

Write a program/function to {explain functionality} in {programming language}

代码转换

我们经常需要将给定的代码从一种编程语言转换为另一种编程语言。这可能是因为组织改变了其技术堆栈。在学习新编程语言时,了解如何使用另一种语言实现相同任务也是很有帮助的。

示例:

Convert the following {programming language 1} code to {programming language 2}: {code snippet}

让ChatGPT扮演口译员

ChatGPT还可以扮演口译员或编译器的角色。为了实现这一目标,我们不需要下载任何东西。这使我们能够在浏览器中编写代码。它可以在测试/实验命令或学习时使用。

示例:

I want you to act like a {programming language} interpreter/compiler. I will give you {programming language} code, and you will execute it. Do not provide any explanations. Do not respond with anything except the output of the code. The first code is: {code}

关于网页设计的咨询

我们可以向ChatGPT咨询关于我们网站的UI/UX设计的任何问题,以便在没有设计团队的实际帮助下,首先为它提供一个更好的外观。

示例:

I want you to act as a web design consultant. I will provide you with details related to an organization needing assistance in designing or redeveloping its website, and your role is to suggest the most suitable interface and features that can enhance user experience while also meeting the company’s business goals. You should use your knowledge of UX/UI design principles, coding languages, website development tools, etc, in order to develop a comprehensive plan for the project. My first request is “I need help creating a {website type} for {purpose}.”

建议一个框架

在开始一个项目之前,选择正确的框架或库非常重要。它会对项目的性能、可扩展性和复杂性产生巨大影响。而且,通常很难决定使用哪个框架。但是,我们可以利用ChatGPT来获得想法。

示例:

Can you recommend a suitable front-end framework/library for my website?? I’m making {type of website}.

编写代码注释

在编写程序时,编写注释非常重要。这些注释有助于在以后理解特定函数或代码块的功能,并可以帮助新加入者理解代码库。ChatGPT可以帮助我们为给定的代码片段生成适当的注释。

示例:

Regenerate the code snippet below, but please include comments on each line of code {enter code}

生成Readme文件

Readme是存储库的重要组成部分,其中包含存储库的用途以及下载和/或使用项目(如果有)的指南。编写良好的readme有助于吸引更多人访问您的存储库。

示例:

Generate documentation for the code below. You should include detailed instructions to allow a developer to run it on a local machine, explain what the code does, and list vulnerabilities that exist in this code. {enter code}

生成Dataset

在处理机器学习项目时,数据集非常重要。如果我们无法找到合适的数数据集或需要更多数据来训练我们的模型,我们可以使用ChatGPT来获取生成的数据,而且还可以获得所需格式和数量的数据。

示例:

Generate {type of dataset} dataset containing {n} data points regarding {service or product} with fields including {fields}



推荐文章