Sometimes we fall into these traps because of our environment. What I mean by that is that bosses or clients come to us w/ specs for software, but with budgets (time and/or money) that do not match what would be needed if we were to truly do things properly. There’s a pressure to get things done and out the door / into production asap instead of 100% perfection. So, as clever programmers, we can sometimes find shortcuts. Sometimes it’s a $$$ thing… like, if a client says, “I’ve got $5k to make this work” but it’s really a $10k project. So, you do what you can to get them a working program… and all is happy until later on when they inevitably want to expand or alter functionality, and you then have to take 2x as long as you would need to if you’d done things properly to begin with. I’ve warned clients about this & they’ve still opted for the “just do it as fast as possible” route. In one particular case I can remember, a script became so spaghetti-ish over about 6 months of constant changes (all during which the client didn’t allow me to recode properly from scratch), I included a disclaimer in the comments, meant for the next poor soul who had to deal with things.