Always code as if
the guy who ends up maintaining your code
will be a violent psychopath who knows where you live.
John Woods
The ToBeWise™ quotation above popped up on my EZchecklist, and it got me thinking about the imperfection of my own coding...
After experiencing first hand the spectacular abilities of AI, I couldn't resist the temptation to request a complete rewrite of the underlying Apps Script governing some of the special features of EZchecklist.
I described what I wanted the AI to program, in English, and it produced the code to produce the result. It was a "clean sheet of paper" approach as opposed to asking for an optimized version of my own code.
The first result showed me that I needed to be more clear and precise in my description of the problem, but after I got the hang of it, the results were clearly superior to what I would have done. I was surprised that the AI even built in reasonableness checks on human-entered data and issued warnings for non-numeric input, etc. (something I had not requested, but definitely desirable). The code was even well documented with comments describing what was going on for each major step.
When the AI produced a code snippet that was unfamiliar to me, I simply pasted that snippet back with the question "What does this do?" and it gave me a thorough explanation. What a great way to learn!
Although this new version is functionally the same as the previous version, it runs faster, is more concise, more adaptable to edge cases, works better on mobile devices, and more clearly written. It's a most excellent Christmas present to myself, and a great foundation for what is to come in the New Year.
While I was building a more perfect product, I also went through and cleaned up some cosmetic issues. So it is now perfect and more beautiful... until the next time I decide to do something extraordinary.