My Approach to Using AI with Programming

It’s pretty clear at this point that AI, in one way or another is here to stay. I imagine at some point the hype will settle, hopefully not crash and this plane will land safely in some new exotic paradise. I’ve observed other developers that range from AI enthusiast to AI avoiders, and like a lot of things, I feel like I fall somewhere in the middle. In terms of AI and my usage of it, I’ve described myself as “cautiously optimistic”.

I feel like if you are on one of the extreme ends of this range, you might be carrying more risk. If you don’t use AI at all, you might be missing out on learning new things and maybe even productivity. If as an AI enthusiast you over rely on AI, you might be accumulating security risks and technical debt by building a large codebase that you don’t fully understand.

Knowing that this must be true in my eyes, what is my approach to using AI, it’s a tool, how do I safely use it?

Protecting Your Mental Model

One thing I may have taken for granted before the AI boom was that when I’m building a component or feature, I’m not only writing blocks of code, I’m creating a mental model of how the thing works at the same time. So when I outsource the writing to AI, I’m also outsourcing that mental model. This to me is not acceptable and indicates that I need to bring a new step to the process. I’ve found that if I read the code that AI has provided, line by line, I start to reclaim this mental model.

If you read the code and understand the structure of what you are building, you will have more confidence in the thing.

Small feedback loops

For me one of the irritating things about responses from AI was just the sheer length of a response. Because I need to actually read and understand the response in order to know if it is useful to me, I ask for shorter responses. When coding I ask for smaller code adjustments, I contain the discussion to a particular part of the codebase. This increases my chance of understanding the change and updating my mental model.

Keep Testing

This seems obvious to mention, but just like we test our code, we should test the code provided by AI. We should also be leveraging AI for test case writing. In fact I feel like testing our code is where AI should have started off, that would be the least risky and most beneficial to the actual codebase.

Vibe Coding/Learning

Vibe coding is a great way to let it rip and get into something that you otherwise would not have. It’s a great way to discover new corners of technology for yourself. To me is a phase you use to explore before you get into the serious phases described above. You don’t have to burden yourself with the building of a strict mental model, you can just see where it goes and that is fun. That makes it a powerful learning tool, it being fun.

Comment section

Leave a Reply

Your email address will not be published. Required fields are marked *

caret-downclosefacebook-squarehamburgerinstagram-squarelinkedin-squarepauseplaytwitter-square