AI assistants in coding: Difference between revisions

From LemonWiki共筆
Jump to navigation Jump to search
Tags: Mobile edit Mobile web edit
Tags: Mobile edit Mobile web edit
Line 91: Line 91:


=== Prompt for Find Problems (or fix this) ===
=== Prompt for Find Problems (or fix this) ===
 
Example 1
<pre>
<pre>
Help me fix the problem
Help me fix the problem
Line 102: Line 102:
source code ...
source code ...
```
```
</pre>
</pre>


 
Example 2
<pre>
<pre>
Help me fix the SQL query
Help me fix the SQL query
Line 117: Line 116:
SQL syntax ...
SQL syntax ...
```
```
</pre>
</pre>



Revision as of 00:24, 21 February 2024

AI Assistants in Coding


Usages

  • Write documentation (or Generate Docs)
  • Convert file to another language
  • Refactor the following code (or simplify this)
  • Explain the following code
  • Generate Unit Tests (or generate tests)
  • Generate Code
  • Find Problems (or fix this)

Prompts cases

Prompt for refactor source code

Prompt

refactor the code

```
(place your source code here)
```

Prompt for function name suggestion

國語版

請提供函數名稱修改建議,函數命名指南:
- 功能明確性: 名稱應清楚描述函數作用,如「檢查」、「解析」。
- 簡潔性: 選擇簡短具體的名稱,提高可讀性。
- 一致性: 遵循項目或語言的命名慣例。
- 可讀性: 使用完整單詞,避免不明確的縮寫。
- 反映返回類型: 若函數返回布林值,考慮使用「is」、「has」等前綴。
- 避免歧義: 名稱應清晰,不與其他函數混淆。
- 反映數據類型: 如果處理特定數據,應在名稱中指明,如「JSON」。

```php
附上程式碼
```

英文版

Function Naming Guidelines:
- Function Clarity: The name should clearly describe the function's action, such as "check," "parse."
- Conciseness: Choose short, specific names to improve readability.
- Consistency: Follow the naming conventions of the project or language.
- Readability: Use complete words, avoiding unclear abbreviations.
- Reflect Return Type: If the function returns a boolean value, consider using prefixes like "is," "has."
- Avoid Ambiguity: The name should be clear and not confused with other functions.
- Reflect Data Type: If handling specific data, this should be indicated in the name, such as "JSON."

```php
source code
```

Prompt for Generate Unit Tests

JetBrain 推出 AI Assistant 外掛功能,目前付費客戶可以免費試用 7 天。它下的 prompt,供大家參考

國語版

為 "XXXClass" 類別中的 "xxx" 方法撰寫 "XXXClassTest" 測試。 指南:

- 撰寫類別和方法的測試描述。
- 測試檔案應該是完整且可編譯的,不需要進一步的操作。
- 確保每個測試專注於單一用例,以保持清晰和可讀性。
- PHP 測試檔案必須以 PHP 開頭標籤 ?php 開始
- 生成的測試類別應該在命名空間 XXX
- 檔案:XXXClass.php

```php
附上程式碼
```

英文版

Write "XXXClassTest' tests for the
'xxx' method in the
"XXXClass' class. Guideline: '*' 
- Write a description of the class and the method being tested. 
- Test file should be complete and compilable, without need for further actions. 
- Ensure that each test focuses on a single use case to maintain clarity and readability. 
- PHP test file MUST starts with php opening tag ?php 
- Generated test class should be in namespace XXX''* File: XXXClass.php 

'''php ?php class
XXXClass {  ... 
'''

Prompt for Find Problems (or fix this)

Example 1

Help me fix the problem
'''
error message or error description ...
'''

Relevant Source Code:
```
source code ...
```

Example 2

Help me fix the SQL query
'''
error message or error description ...
'''

SQL Query in Question:

```
SQL syntax ...
```

相關 GPT 機器人

GIT message generator by OpenAI

相關網頁