| Version 2 (modified by , 43 hours ago) ( diff ) |
|---|
Why AI for coding?
- Efficient: automatic code/documentation generation
- Speed: accelerate data analysis pipeline development
- Troubleshooting: get instant help with complex R/python errors
What is an AI Coding Assistant?
- Definition: Large language model (LLMs) trained on massive code datasets.
- Key capabilities: Code generation, code completion, Documentation, Language translation (e.g., python to R)
Set Clear Expectations
AI is a pair programmer, not a replacement for developer judgment. It accelerates work but requires human oversight.
Key Features of AI Coding Assistants
| Feature | Description |
|---|---|
| Code suggestions | Provides code suggestions based on comments and file context |
| Context-aware completions | Offers context-aware code completions based on all or a part of the codebase |
| Test generation | Analyzes code to generate tests |
| User-IDE interaction | Automatically provides guidance as users type code in the IDE; Chat within IDE |
| Code analysis | Analyze code snippets to provide reliable code prediction and tag suspicious code |
| Bug detection and fixing | Identifies bugs and suggests to fix them |
| Code autodocumentation | Automatically adds docstrings and enhances code documentation |
| Routine task automation | Helps with code creation for routine or time-consuming tasks |
| API and SDK usage optimization | Aids in making correct and effective use of APIs and SDKs |
| Open source discovery and attribution | Facilitates discovery and attribution of open source code and libraries |
*Source: AI-Assisted Programming, by Tom Taulli (O’REILLY)
Popular Tools for AI coding
- Chat-based (ChatGPT, Gemini, Claude) Best for: reasoning, debugging, learning, prompt iteration
- IDE-integrated (Github Copilot, Cursor, Claude Code) Best for: writing code faster inside existing projects
General guidelines when using AI for coding
1. Clear Problem Definition
- Best Practice: Before asking ChatGPT for help, clearly define the problem or task. A well-defined question improves the quality of the response.
- Example: Instead of saying “Fix my code,” provide context such as “I'm trying to optimize this Python function that clusters the sequence alignment positions in proximity recursively, but it's too slow for large inputs. How can I improve it?”
2. Break Problems into Smaller Chunks
- Best Practice: For complex tasks, break the problem down into smaller, manageable steps. Ask about each step individually to get focused and accurate assistance.
- Example: Rather than asking for a full solution in one go, ask for help with specific functions, then how to test them, and finally how to integrate them into your larger project.
3. Iterate and Refine Your Questions
- Best Practice: If the initial response isn’t quite right, clarify your question and ask for refinement. ChatGPT often improves its responses based on follow-up queries.
- Example: “The solution works, but it doesn't handle edge cases where the input is negative. Can you adjust it?”
4. Ask for Explanations, Not Just Code
- Best Practice: Don’t just request code; ask for an explanation of how and why it works. This helps you learn and apply the knowledge in future problems.
- Example: “Can you explain why you're using a heuristic search algorithm here and how it improves the time complexity?”
5. Use ChatGPT for Code Reviews
- Best Practice: Ask ChatGPT to review your code for potential improvements in readability, performance, or best practices.
- Example: “Can you review this Python function for any inefficiencies or suggest improvements for readability?”
6. Leveraging ChatGPT for Debugging
- Best Practice: Provide the exact error message and a concise description of what the code is supposed to do when asking ChatGPT for debugging help.
- Example: “I’m getting a TypeError in this Python code when trying to perform a log transformation. Can you help me identify why this is happening?”
7. Specify Language, Framework, and Version
- Best Practice: Always mention the programming language, framework, and version you're using to avoid receiving outdated or incompatible code.
- Example: “I have a Python script created by Python 2.7. Could you please modify it to be compatible with Python 3.8?”
8. Request Test Cases
- Best Practice: Ask for test cases when getting help with functions or algorithms to ensure the solution is robust.
- Example: “Can you provide a few test cases to verify that this sorting algorithm works with edge cases like empty lists or lists with duplicate values?”
9. Use ChatGPT as a Learning Tool
- Best Practice: Don’t just use ChatGPT to get answers—use it as a learning resource. Ask it to explain new concepts or techniques introduced in its responses.
- Example: “You used dimentionality reduction in this solution. Can you explain what that is and when it should be used?”
10. Understand Limitations and Double-Check Critical Code
- Best Practice: ChatGPT might not always produce the optimal or correct code, especially in complex scenarios. Always review and test the code yourself.
- Example: After receiving code from ChatGPT, test it thoroughly, and if it’s a critical part of your project, cross-reference it with documentation or experienced developers.
Note:
See TracWiki
for help on using the wiki.
