There’s a myriad of AI tools and integrations out there that can help you with your day-to-day coding. However, we wanted to show you seven ways that the Tilt developers are using plain old ChatGPT to make their lives easier.
1. Regexes
There’s a weird subset of developers that pride themselves on their ability to write regexes. For the rest of us they’re a bloody nuisance. My absolutely favourite use of ChatGPT is generating regexes. You explain what you’re looking for a regex for, it generates it, and then we use https://regex101.com/ to validate with some example data.
Done.
2. Optimising code
You’ve got a function, you glance at it and it’s immediately apparent that this has been worked on by lots of devs over quite a long time. You could spend half an hour refactoring it, but let me tell you, pop it in ChatGPT, and in a few seconds you’ve got a function back that’s clean and still works.
As with anything ChatGPT related, a good set of unit tests and some visual and manual validation are also needed! But honestly, no more than if you’d manually refactored.
3. Debugging
You’ve got an error message. You look at it. You look again. You make a change. Why didn’t that fix it? You Google the message just to see if it’s a misleading error. It’s not. You’re missing something obvious…
One paste of the area of code and the error message, and it normally highlights the issue. With SQL queries it’s especially good at rewriting and removing the issue, especially when it’s something simple like a misuse of aggregation, etc.
4. Recreating bugs
You’ve got a ticket from a customer with screenshots attached. You try to recreate it. You can’t. You get your team to try and recreate it. They can’t. You all sit, trying to figure it out. Welcome ChatGPT. This is one of my favourites, giving ChatGPT hypothetical situations and asking it to think how the situation could have occurred.
A part of this is just rubber ducking, in that having to quantify the issue for ChatGPT sometimes makes you realise what the issue is and how it could have occurred, but it’s a great second brain to bounce around ideas with.
5. Checking for vulnerabilities
Being a dev, we generally keep up on known vulnerabilities in code and security best practices when building applications; however, the world moves quickly, and we’re only human. I love using ChatGPT to double check my code for any vulnerabilities I might have missed.
6. Documenting *those* functions
Every codebase has those functions, the ones that no one wants to go near, the ones that really need solid documentation, and explaining what they do. Yeah, you can paste those into ChatGPT and ask it to explain what they’re doing. It might miss nuances, but it very quickly gives you an overview of what is going on.
You can also ask it to write documentation for your code as well, because let’s face it, everyone understands why documentation is important, but no one likes writing it!
7. Bulk formatting changes
We all inherit codebases at some point in our lives. Say you’ve got a codebase that sometimes someone has used camel case, and sometimes snake case, sometimes even in the same functions. We all have linters and a set of company standards (well, teams of a certain size will!), but there are still changes that linters can’t make, and sometimes there are some changes needed that are beyond the capabilities of a linter. Yeah, ChatGPT is good for that.
Either explicitly stating what needs to be changed or in some cases, just giving it one code sample as a template and then asking it to make sure every sample after it is replayed with the same conventions.
So, there we go; these are the seven ways Tilt devs are using ChatGPT to make their lives easier. Please tell me at sarah.stevens@wearetilt.com the other things you’ve been using ChatGPT to make your coding better!
SHARE: