As a member of the coding community, I believe that ChatGPT, the AI language model created by OpenAI, is a valuable resource. The model’s ability to explain assumptions and nuances when making recommendations empowers human users to make better-informed decisions. The AI’s capacities for summarizing industry-standard tools and simplifying complex concepts are major assets. However, while ChatGPT is a powerful and accessible tool, it is currently limited. Here are some helpful tips to maximize the potential of ChatGPT while coding.
For my first test, I asked ChatGPT to provide a simple terminal command. "Nice!" I thought as I received a correct answer. But let's be real, a quick Google search would provide the same assistance. So, I decided to test ChatGPT’s intelligence further by requesting a more advanced task: generating a Typescript React component. My excitement quickly faded as I encountered five compilation errors after copying the code into my IDE. However, I didn't give up on the AI chatbot just yet. I tried again, this time initiating the conversation with "pretend you are an experienced full stack software engineer." This led me to Jane and her quality of code definitely increased as a result.
Tip #1: Prompt ChatGPT to Impersonate an Expert in your Domain of Interest
As our conversation progressed, Jane recalled earlier exchanges. Unlike Google, ChatGPT has memory capabilities. This allows you to refactor as you go. As a simple example, I asked Jane to update previous code she generated to use a new variable name.
Remember, you're the true code wizard, not the AI.
Tip #2: Break the Problem into Smaller, Manageable Tasks for ChatGPT
Gradually build solutions with the AI’s assistance. While the artificial intelligence excels at predicting subsequent words, it struggles to comprehend the interconnectedness and dependencies within the text. Recognizing the impact of one line of code on another, especially at opposite ends of a block, is a task that requires your human diligence.
While ChatGPT doesn’t automatically generate tests when prompted to be a Test-Driven-Development enthusiast, it does provide a good starting point after being explicitly asked. The AI assistant can be a helpful tool for those following red-green-refactor patterns, as it can assist with smaller chunks of functionality.
As I learned when copy-and-pasting the whole React component into my IDE, the AI won't magically generate correct complex code. The code appears functional but often contains small errors. Even when asking ChatGPT to pretend to be an expert and produce a moderately simple component, the resulting code looks good at first glance, but closer review surfaces mistakes. Here is an example, where Jane, the ChatGPT persona, chooses to use
makeStyles, a Material UI hook that was deprecated in v5.
Tip #3: Iterate!
Ask it to evaluate itself like I did by asking it to check its last message for any errors. Word of caution, limit reevaluations to once or twice in the same chat as I saw ChatGPT loop itself through errors. If you notice repeated mistakes, start a new conversation with your learnings (and don't forget to ask it to impersonate an expert again).
When (inevitably) you encounter errors and commence on the debug journey, don't simply paste the error into the chat, expecting a result similar to a StackOverflow post. Pairing with ChatGPT requires a shift in mindset.
Tip #4: Inquire About its Reasoning Behind a Specific Term
This provides insights into its intentions, allowing you to take advantage of that knowledge for debugging.
Tip #5: Bring in Some Help
You can also request alternative solutions or continue using other tools like a human pair, an IDE, or classic Google. Keep in mind that ChatGPT's knowledge of recent technologies may be limited after 2021, as stated in OpenAI's documentation.
Tip #6: Think of ChatGPT as a "Search the Web and Summarize" Tool
This will help you ask better questions and receive more helpful responses. As a coding companion, ChatGPT really shines when explaining different coding patterns and tools. I love its ability to offer fresh, creative insights that are not limited to the most upvoted answer on StackOverflow. By tapping into ChatGPT's unique perspectives, I am able to innovate and build beyond my own coding skills and ideas.
Take a look at this cool video that demonstrates how the AI chatbot can help you with your coding projects! ChatGPT and I collaborated to create a new website using Django and Typescript React. The AI was solely responsible for the styling, and we worked together to implement the drag-and-drop functionality. The website may not be the most glamorous, but ChatGPT proved to be a helpful tool in the development process.
Like many human developers I’ve paired with, ChatGPT is a quirky, entertaining, and sometimes helpful coding companion. While the AI cannot magically generate vasts amount of code, its ability to simplify the coding process and make it more accessible to all backgrounds is impressive. By applying the tips I've mentioned, ChatGPT's contributions can bring even more value to your coding journey. So don't hesitate to explore this powerful tool and make the most out of its capabilities. Happy coding, friends!
If you have a development project in which you will be integrating ChatGPT and would like some expert help from our Focused Labs consultants, complete our Contact Us form and we will have a human chat.