How often do you tidy your code?

Godot Version

4.4

Question

This is a general question.

So when we code, we sometimes think of better ways to do something, or sometimes we need to do change the codes around so the game could run better, etc.

But changing or optimizing structures of the codes take valuable time and perfection could only be chased but never be caught.

Normally, if a game works already fine with strange, unnatural or messy spaghetti code, will you tidy up the code? Or do you prefer to leave it be because it already runs fine? When should you tidy or not tidy up the code?

Personally, I try not to let things get to a state where there’s spaghetti; it makes maintenance and adding new things a pain. If I’m experimenting and wind up making something that works but is a mess, I’ll generally clean it up immediately, since that’s the point at which I understand it best. If I have to come back to it in a month or a year, I’m going to have to figure it all out again before I can even start to dig in to it.

That’s less true for things like performance or using suboptimal data structures. If I’ve got some code that’s working and relatively clean, but slow, I’ll potentially leave that for a long time before I get to it. Particularly if it’s something like run-once lightup code where optimizing it just means the game will start 3ms faster.

The “how quickly will I get to fixing it” question is mostly a function of complexity; things that will be hard to re-learn later I fix now while I still remember how they actually work. Things that are easy to fix later I’ll fix whenever, or maybe never fix if it turns out they don’t need fixing.

3 Likes