Learning to Code? Fall in Love With Errors

Learning to Code? Fall in Love With Errors

Subscribe to my newsletter and never miss my upcoming articles

Learning to Code? Fall in Love With Errors

Don’t fear errors. You’ll become a better developer when you embrace failure

Coding Can Be Frustrating

Let me share a personal story. I first started coding when I was 14. I liked playing computer games, so I assumed that creating them was a natural next step. For a bookworm used to learning things fast, learning to code didn’t seem like a big deal. So I bought a book about C++, downloaded a text editor, and started coding.

My first application was about ten lines of code. It didn’t work. I forgot about three semicolons in those lines. I got a little bit frustrated, fixed errors, and reran the program. It crashed again. This time, there was a typo. It took me almost an hour to make a trivial app work.

I stuck to coding for about two weeks. I just couldn’t handle the frustration of failing time after time. It took me over ten years to try programming again just because of some typos and missing semicolons.

Image for post

Photo by Jackson Simmer on Unsplash.

Things Go Wrong All the Time

I’ve been programming for five years now, and I’ve made some progress. Nevertheless, I still get stuck almost daily. The thing is, programming is hard. And as we all know, everything that can go wrong will go wrong. It’s only a matter of time.

For programmers, buggy code is a natural state of things. Whether it is some unhandled error in nested asynchronous code or a missing semicolon, mistakes happen all the time.

Change Your Perspective

As an aspiring developer, you have to prepare for numerous setbacks. You have no choice but to befriend failure. As the infallible Samuel Beckett wrote:

“Ever tried. Ever failed. No matter. Try Again. Fail again. Fail better.”

Although Beckett probably had something bleak in mind, the quote is a piece of sound advice for beginner developers.

But I know better than to think that one inspirational quote will be enough to convince you that failure is OK. So I’ll demonstrate how you can like errors or maybe even fall in love with them with a mindset shift.

Image for post

Photo by Nadine Shaabana on Unsplash.

Here are some common attitudes towards errors and tips on how to reframe them.

“That error is stupid.”

Maybe. Some errors are stupid. But someone put them there for you as a clue about what went — or could go — wrong. Errors are there for you to understand what’s happening and they usually go with helpful advice.

Imagine having real-life error messages. For example, your partner seems angry at you, but you have no idea why. Thanks to excellent error implementation, you get a text message saying, “429 Too Many Requests.” Now you know she’s just tired, so you should try to help instead of wondering what you’ve done wrong. Wouldn’t that be helpful?

“Another error? That’s enough.”

I’m sure you know the feeling. You’ve spent lots of time fixing an error. Now the code has to work. And it works! But two lines below… there is another error. It looks like you’re stuck in an endless cycle of new errors.

But is that a bad thing? That’s a new error. A unique opportunity to expand your knowledge. As long as your errors are changing, you’re making progress. If you’re failing, you’re learning something. When your code is perfect, you’re in your comfort zone and learning nothing.

So try a different approach. Next time you encounter a brand new error, say to yourself, “That’s interesting. I’ve never seen that error before.” Let’s see what you can achieve with such a mindset.

“That bug is hard. I’ll start with something else.”

This is the tricky one. You can easily convince yourself that it’s reasonable to warm up with something easy and then get to the real business. But be careful — maybe you just want to procrastinate and avoid another failure.

You have the best chance for a breakthrough when you are rested. Try starting with the most challenging task. Don’t worry if you fail. At least you may learn something new.

“I’ve wasted three hours on that error and have gotten nowhere.”

So what? Nobody’s hurt. You’ve merely “wasted” some time. But did you really waste it? Maybe you just learned something.

Now you know some approaches don’t work. If you’re lucky, you may even have some idea about what may work. That’s how you make progress. Embrace the failure, feed on it.

Also, imagine the satisfaction when you eventually solve the problem. Be proud of your achievements.

“I’m tired of this. I need to rest.”

This one is productive. More often than not, taking a break is an excellent idea if you’re stuck. Try taking a walk, chatting with a coworker, or anything else that will help you reset. The problem is unlikely to get more serious while you’re taking a break.

I’ve got one extra tip: If you’ve rested and still can’t solve the issue, try tackling it right before going to bed. You may think your brain is resting while you’re sleeping, but in reality, it’s working hard. So there is a fair chance you’ll have your solution just after you wake up.

 
Share this
Proudly part of