A lesson in not repeating yourself.

Not repeating yourself is a big part of writing stable code. You start writing the same code in three places and changes become a real pain. More importantly, it’s very easy to forget something and end up with buggy programs.

But it’s easy to overlook a little bit of repetition. You’re in a hurry or dealing with an existing code base or whatever. But this is never a good idea as I learned…

We have an app where users pay a subscription fee through paypal. There are two separate actions – subscribe and renew – which send the user to paypal along with the necessary parameters (price, subscription type, etc.).

Two actions doing pretty much the same thing? Yep, that means repetition.

So, we were running some tests on the payment process and, to do so, had set the subscription fee to a penny. We got everything sorted, reset the subscription fees, and deployed our changes. Of course, we forget to reset the fees in the renew action.

The very next day, a customer renewed their subscription for the low, low price of one cent. So annoying. Anyway, can’t stress it enough – don’t repeat yourself.

Tags:

Your thoughts?

Preview