Are you a bug magnet?

Do you attract programming bugs like
A moth to a flame
A fly to rubbish
A cockroach the same
An ant to food dish

Are you a code bug magnet?

Recently, I was having dinner at a pasta restaurant. Now, when I ate at (fast food) restaurants, there seemed to be these unwelcome guests. They fly and they crawl.

Who were these guests? They’re bugs. And they bug me real good.

They linger on the table and test my patience as to how close they can get to my food. They scheme to land on my drinking straw just so I have to go get another straw. My only weapons were the blow (without expectorating my food), the wave (shoo shoo), and the ignore (hope you go away…). Generally, the better restaurants have fewer of these six-legged visitations.

Anyway, back to the pasta restaurant dinner. It came to my attention how fast the waiters and waitresses move to clean up the dishes. The moment you’re done, someone comes over to you and ask “Can I clear that for you?”. Well, it’s rhetorical, because they continue to take that plate from you anyway.

Now, for comparison, there’s another restaurant I visited. As I was eating, I saw a baby cockroach crawling around. Flies I can understand. Ants I can understand. But cockroaches were the last straw. I boycotted that restaurant.

On reflection, I realised this restaurant’s helpers were slower in cleaning up tables. As a result, the unfinished food in the dirty plates and bowls naturally attracted bugs. Slow business is not an excuse to take your time keeping the place (and tables) clean.

Now here’s the point: Once the bugs come, they are hard to get rid of. Even after you clean up, they’re still there (for a while at least). It’s like they have some memory of food being there, so even if the food isn’t there now, it’ll probably be there in a while. So the bugs stick around.

Moral of the story

Once you have messy code, you attract bugs. Once the bugs are there, it’s harder to get rid of them completely. Your best bet is to not attract them in the first place, by writing good code.

Since all humans are imperfect, therefore all code written by humans are imperfect*. That said, what you can do is write good code as best as you can. Just as restaurants (and food outlets in general) inevitably attract bugs, restaurants can still keep the place clean so as to attract less of them critters.

I don’t have a good definition of “good code”, but I do know that you need help if someone asks you (in resignation), “Are you a bug magnet?”.

P.S. Lately, I tried that restaurant that was boycotted. The place seemed better kept. My dining experience improved once those exoskeleton-donning buggers were out of my face.

* To forestall your question, no, code written by computers or robots are also imperfect. Who do you think created them computers and robots in the first place?

  1. Ben

    The value of good clean code is tremendous. I started coding when I was still in elementary school with out any formal education in the field. Back then I wrote really messy unstylized code.
    In fact I wrote code like that up into my late teens. Hey it worked and run smoothly – used the least amount of systems resources it could and ran fast. I thought no one sees the source so who cares.
    Well I later learned that if you go back to your source code after a couple of years and its a mesh of spaghetti code it is pretty much useless. It does attract bugs for sure.
    Now I revel in writing clean code well laid out and stylized code. I make the source look good, and I comment too (granted my comments me be cryptic to anyone else). I have to say, clean code does attract less bugs.

  2. Vincent Tan

    My source code looks good too… 🙂 I think it might have been something from my math background. Math proofs are well laid out and written with logical arguments.

    So when I started (coding), I was a bit obsessed with indentation, meaningful variable names and lean mean algorithms. Spaghetti code makes me itch…

Comments are closed.