CLUTTERED CODE
In this video, learn how to declutter your code and improve readability using Apps Script and AI tools like ChatGPT. Discover practical tips for managing your Gmail and enhancing your coding efficiency.
So you have a cluttered code, or you're trying to code, you're trying to vibe code, you're trying to use ChatGPT or Gemini or whatever, and you're trying to figure out, "How do I keep all the code going? And I'm getting, like, bigger and bigger and longer code, and it's getting cluttered. It's getting hard for AI to do. It's hard for AI to, like, tell me what to do in the code. How do I figure this out?"
We have a ChatGPT tab open, and we're copying and pasting the entire code over to ChatGPT, and things, some things happen. Like, uh, for instance, it'll tell you to edit something, and you wanna cop- and you want to just copy and paste and edit, but you don't know where it is.
Uh, the first thing I would say, though, is go to bettersheets.co and get the course Spreadsheet Automation 101. This is gonna give you a base to run and execute functions inside of Apps Script and be able to start reading.
So it gives you a command center here where I can write a bunch of- accounts, uh, um, email addresses that I get email from them, but I just want it immediately archived.
a bunch of emails and I'm like, "Okay," I get to a point where I'm like, "I just need to quit for the day," but, like, if I open my inbox, I'll see something, and it triggers in my brain to, like, try to do something, but then I feel guilty.
executes a few things, that creates labels, that will set up everything. It will also, um, enable these automations. But I wanna do more. Like, if, if a user wants to add something and they ask me…
faster and bigger and better, and do it without us having to trudge through it. I'm gonna show you the prompt.
One person is anyone else who wants to help me. For example, this tool that I'm gonna build, it's a sheet, it's a template where you have stuff to work in the sheet.
and say, "I wanna do this." And that's gonna, like, cause more problems. Causes more hallucinations.
So why do we care about how many tokens it is? Well, we're using free ChatGPT.
So I'm, I'm not using paid ChatGPT right now. I just wanna share this with you that it's free.
gonna do all caps code, current code. I'm gonna paste this here. So that's the existing code, and I'm gonna keep writing this prompt.
So comment every line in a human-readable way, and I want it to do something else.
I'm like, what the heck is that? That's the only place where att is exists.
any functionality, but rather rewrite it so that I can just read it as a person.
I don't know everything possible. I also don't know much about JavaScript.
And this is me writing this, and if you have an example, like if you say, "Okay, this is like a great comment .
So what I usually do at the top of a function , though, is not this inline one.
Give it some context of you. I've been using Apps Script and coding myself for years.
But that's usually, that's usually what gets me in the most trouble is when I'm doing things I don't understand.
For functions that are quick and small, please only write a few words.
It's gonna have that feeling. What we're asking AI to do right now is actually literally probably the greatest thing that AI can do, which is just rewrite stuff.
this is sort of one of the funny things that I actually enjoy doing.
We are telling it, "Here's what you need to do. Here's why," and, and the tone of what we're doing here, what you think to do.
There you go. Let's do that. Let's, let's give it this new code.
Yep, yep, yep. Okay, cool. Wow. And then it just keeps, keeps, keeps going.
Okay, so it got to the end. I think this is the last part of it.
I can go one of two directions. I could just add a bunch of comments , now I can read what each of these things do.
have been very difficult for me, and if they're also difficult for you, find some regex , have ChatGPT explain the heck out of it in your code.
just go to bettersheets.co/consulting. This is bettersheets.co/consulting.
now to get more tips, tricks, how tos, get more out of your Google sheets than you ever have before.