If you’re new to using large language models (LLMs) like ChatGPT in software development, you might find yourself following a familiar pattern:
- Writing a prompt
- Copying and pasting the generated code
- Not fully understanding everything, but as long as it works, you run with it
- Telling yourself, "If it works, don't touch it."
While this approach might seem efficient in the short term, it's not sustainable if you want to grow as a developer.
A simple tip to help you get the most out of using LLMs for coding:
💡 Focus on understanding what you're doing, not just getting the code to work.
Here’s how you can level up your LLM usage:
1. Ask for Explanations of the Code
After generating code from an LLM, don’t just settle for the output. Write a new prompt asking the model for a step-by-step explanation of what each part of the code is doing. This will help you understand the logic behind it.
2. Clarify What You Don’t Understand
If there are parts of the generated code that don’t make sense, ask about them specifically. LLMs can break down complex code into more digestible explanations if you request it. Understanding these details is crucial for your growth as a developer.
3. Test Your Understanding by Rephrasing
After getting an explanation, test your understanding by writing a new prompt that explains the code in your own words. This forces you to engage more deeply with the problem. If the model's response matches your explanation, you're on the right track. If not, you’ll know exactly where your gaps are.
4. Iterate Until You Can Explain It
Continue asking for clarifications and refining your explanations until you can confidently describe every part of the code as if you had written it yourself. This process ensures you're not just copying and pasting but truly grasping the underlying concepts.
5. Reach Out to More Experienced Developers
When you're still stuck or unsure, don’t hesitate to ask a more experienced developer on your team. A short conversation or call can clear up confusion much faster than struggling on your own and can save you hours of confusion.
By taking the time to understand the code you're working with, you'll avoid common pitfalls such as:
- Tedious code reviews: Submitting code you don’t fully understand can lead to painful, lengthy feedback sessions.
- Awkward moments in pair programming: It’s hard to collaborate effectively if you can’t explain what your code is doing.
- Unnecessary discussions: "I copied and pasted it from ChatGPT" isn’t an acceptable response when someone questions your approach.
LLMs can be an incredible tool for accelerating learning, whether you're adapting to new languages, understanding libraries, or designing software architecture. But to use them effectively, you need to learn and internalize the basics. This will not only help you avoid embarrassing moments but also ensure that you're growing as a professional.
Remember, it’s not just about making things work, it’s about understanding what you're doing. This will benefit not just you, but also your team and the quality of your work. When used correctly, LLMs become an invaluable tool for learning and problem-solving.
You can thank me later 😉