How Good Are AI Coding Companions? 'It Depends!'
Practical guide for using an AI Coding assistant and improve your productivity.
- a brief overview of AI coding companions
- set your expectations correctly
- the art of prompt engineering
- Tips and tricks
- When AI companions fall short and you're better off coding yourself
Note: If you are interested in learning more about LLMs and GenAI, check out the GenAI space on community.aws
Have a look at some useful introductory videos from my colleagues on this playlist
- The AI will not write perfect code immediately. Expect initial results to be rough and require refinement. The AI may make logical errors or use suboptimal code structures. It may not automatically import the libraries they are suggesting for example.
- Don't expect the AI to understand broader context or objectives. It will generate code based solely on the prompts you provide. Give sufficient background and constraints.
- The AI may struggle with complex logic or novel coding scenarios. Its code generation abilities are best suited for common coding patterns and scenarios the AI has seen before. It can learn from you, from the example you provide, and it is continuously enriched with new code samples.
- You'll need to review, refine, and iterate. The AI should act as an intelligent assistant, not an autonomous coder. Treat it as a partner and carefully evaluate its suggestions. You are in the driving seat.
- Start with simple prompts and builds up from there. As you get a feel for the AI's capabilities, you can increase prompt complexity incrementally.
- Be patient and keep practicing prompt engineering. It takes time and experimentation to learn how to prompt the AI effectively.
- Existing code in the open files and project: The AI reviews current code to infer patterns, style, and domain language. Classes names, methods names, variable names, and imported libraries provide critical context.
- Comments: Clear, concise comments orient the AI towards intended functionality without being overly prescriptive.
- Use intuitive names for code elements like variables and functions, as explained by my colleague Brooke in a previous article
- Test cases: Tests demonstrate required behavior and provide concrete examples for the AI to train on. That's why test-driven development (TDD) is highly effective when working with AI assistants. Writing tests first creates a "specification" for the code. The AI uses these tests as prompts for generating function bodies and other code. You then can quickly validate that the generated code is delivering what you expected. I recommend you to have a look at this video about TDD.
Any opinions in this post are those of the individual author and may not reflect the opinions of AWS.