Spaghetti Code

I was coding Monday this week, and I notice something I was doing, and I’d like to talk about. Me and my programming pair were both guilty of this, but he did it a lot this particular day. So I have been becoming more aware of this in myself. But I’m dancing around the point. There is this process that I call writing Spaghetti Code, which is just writing code that might work and hoping that it sticks. You know, throwing Spaghetti at the wall.

This is a bad thing.

Because, you know sometimes you’re coding, and it almost works, so you think it might be wrong. You think you saw this in an example at some point, so you throw an “@” symbol in there or you add some method or you throw a “:” somewhere to make a symbol. And this might work, you might even get lucky, haphazardly drafting something from memory.

If you’re taking a test, this may be the saving throw you need.

But generally, I think this is bad because you aren’t learning anything, even if you get it right. Spaghetti Coding builds a bad habit, and I think it is important to fully understand everything that you do. If you don’t understand why something works, go look it up, make sure you see what you are doing. Not that you need to more than the API of a library you are using, but you should understand why you’re code is not working. You should read the errors. You should pay attention to what your program does and when, and then you should have a thoughtful conclusions. Not just throwing Spaghetti at the wall. We live in an age where you can Google everything, and you should take advantage of this.

Not that you should take this as saying that you shouldn’t play. Experimentation is important, and part of life is just doing something for the hell of it and observing the result. This is okay, in the context of play, in the context of learning, in the context of experimentation. This is different if you are coding and have a specific expectation of what you are trying to do, and you are guessing instead of working towards learning, understanding how things work. There is a difference between practicing on a guitar for a couple hours each weak, messing around, and practicing with those same hours in a focused way. While messing around is important, it is also important to have a stringent attempt to become better, as well.


Now read this

NaPoWriMo 2017 - Day 28

The Apple Store # In the city there is a shining obelisk glass cathedral of light Mayan geometries windows to the sun boxes upon boxes housing sleeping Things that wish to wake Hollow men and women in blue wear painted, practiced smiles... Continue →