Chapter 2: Code Generation and Debugging
Code Generation Templateβ
Language: \{LANGUAGE\}
Framework: \{FRAMEWORK\} (if applicable)
Task: \{DESCRIPTION\}
Requirements:
- Input: \{INPUT_TYPES\}
- Output: \{OUTPUT_TYPE\}
- Edge cases: \{EDGE_CASES\}
- Performance: \{REQUIREMENTS\}
Include:
- Type hints/annotations
- Docstrings with examples
- Error handling
- Unit tests (optional)
Style: \{STYLE_GUIDE\}
Debugging Promptsβ
Debug this \{LANGUAGE\} code:
```{language}
\{CODE\}
Error message: \{ERROR\}
Expected behavior: {EXPECTED}
Actual behavior: {ACTUAL}
Please:
- Identify the bug
- Explain why it occurs
- Provide the fixed code
- Suggest how to prevent similar bugs
## Code Review
```text
Review this code for:
- [ ] Correctness/bugs
- [ ] Performance issues
- [ ] Security vulnerabilities
- [ ] Code style/readability
- [ ] Best practices
Format:
| Line | Issue | Severity | Suggestion |
|------|-------|----------|------------|
Documentation Generationβ
Generate documentation for this \{LANGUAGE\} \{TYPE\}:
```{language}
\{CODE\}
Include:
- Description
- Parameters (types, descriptions)
- Return value
- Usage examples (3)
- Exceptions/errors
## Key Takeaways
:::tip[Summary]
1. Specify **language, framework, style guide**
2. Include **input/output types and edge cases**
3. Request **explanations** with code
4. Use **structured formats** for reviews
:::
---
**[β Previous: Content Creation](/module_07/chapitre1-content-creation)** | **[Next: Data Analysis β](/module_07/chapitre3-data-analysis)**