I have been using code completion more on small scripts and it is definitely useful for repetitive parts. The problem is that I sometimes accept a 10-line block because it looks reasonable, then five minutes later I cannot explain why one condition is there.
A recent example was a file-processing script. The completion added an exception branch and a fallback value. Both looked sensible, so I kept them. Later I changed another part of the script and realized I had no idea which errors the branch was supposed to catch. Nothing was technically “wrong”; I had just skipped the thinking step.
I am not trying to avoid the tool. I want a way to use it without slowly turning my own code into something I only recognize visually.
One thing I have started doing is accepting smaller chunks and rewriting any block I cannot explain in plain language. I also try to run the code after each meaningful change instead of accepting three suggestions in a row.
That is slower, but maybe that is the point while I am still learning. What habits have actually helped people keep track of generated code rather than just supervise it?
1 reply
Running after each meaningful change is the habit I trust most. It breaks the spell a bit, which is useful when you’re tempted to accept thr...
Running after each meaningful change is the habit I trust most. It breaks the spell a bit, which is useful when you’re tempted to accept three neat-looking things in a row.
I like the “spell” wording. That’s exactly what it feels like when the code looks fine but my brain has checked out.
2 replies
I’ve started deleting more of the suggestion than I keep. The tool is good at filling in obvious stuff, but I don’t want it deciding structu...
I’ve started deleting more of the suggestion than I keep. The tool is good at filling in obvious stuff, but I don’t want it deciding structure for me unless I already know the shape.
This. I only accept generated code if I can predict the next line before I read it. If I can’t, I slow down and write it myself.
That’s a good test. Predicting the next line feels like a decent line between “helpful” and “I’m just nodding at the screen.”
1 reply
Smaller chunks is the big one for me too. If I can’t restate the block in one sentence, I don’t let it stay as-is for long.
Smaller chunks is the big one for me too. If I can’t restate the block in one sentence, I don’t let it stay as-is for long.
I also name the branch in a comment when it matters. Not fancy documentation, just enough to remind me why that thing exists when I come back later.