We developers spend a lot of time thinking about what good and bad code looks like, but we don’t often take time to discuss what good and bad code feels like.
If we did, I think that we could recognize the quality of code more easily. Consider that we can describe spaghetti code in terms of what it looks like, and we can teach that to new developers. That way they can recognize it and avoid making mistakes. But if we discussed what spaghetti code felt like, new developers could watch out for those feelings and develop an intuition about what spaghetti code feels like and why it’s a bad idea.
For example, consider the following scenario: you feel frustrated and overwhelmed because there’s just too much to keep in your head. You feel defeated because you can’t predict how your code will behave – even though you used to be able to no problem!
Does that sound familiar?
I’d say that sounds like you’re using global variables to manage too much state.
Okay what about this: you’re frustrated because you got a bug report, even though you already fixed that bug like five times. You feel lost trying to fix it, the code seems like a maze and every direction looks the same.
I bet you’ve had those feelings – I know I have. That’s what happens when you copy and paste code that’s mostly the same. It had a bug in it originally, and now that bug has been copy and pasted, too.
(Note: In either case, you’re frustrated. Coding isn’t fun when you’re frustrated, which is a shame because many of us got into coding because it was fun. Huh.)
If we got better at recognizing and discussing our feelings, then teaching them to others, I think that we could advance the craft and profession of software development significantly. We would become better coders and enjoy our jobs more. Sounds like a win-win.
One more scenario: you feel like there’s something you just don’t get, but everyone else has it figured out. Don’t worry – everyone feels that way. It’s a normal part of learning, so don’t sweat it!