StackOverflow Pitfalls for Developers

I had a talk with a younger developer yesterday. We discussed that, nowadays, the most important quality of developer is ability to learn new things quickly. Most of the problems have already been solved somewhere, we just need to reuse it.

This reminds me of old time… (no not punch card, I am not that old yet)

When I first started programming, the Internet connection was scarce. I spent most of my time removing code line by line to find where the error was. Once found, I tried to make sense out of the error message. There was no one to ask.

When I didn’t know how to do anything, I consulted either text book or Help documentation. Googling was not that useful. When I found, I felt that I found a gold mine. (The site keeps pieces of Java code for solving problem.)

Life has changed. The developing environment nowadays has significantly changed, mainly

  1. Most problems have been solved – You can find 80-90% of the solution in the Internet. Most of them are with code, ready to copy and paste in StackOverflow.
  2. Open-source has (almost) everything – It is very rare that we need to build anything from scratch. Usage of framework or library is very fundamental for every project.
  3. Information overloaded – We have abundance of resources. We do not have enough time to digest them all.And they all come with different level of quality.

This greatly influences the way I work. In a good way, I am much more productive than I was (Yay!) In the bad way, I develop many bad habits over years, without realizing it.

Hoping that you will avoid the mistakes I made (and I see many others made), I would list them here:

    1. Not really read error messages- There was a time when I had a tendency to… google every error message I found, immediately.  It seemed to work for 80% of the time. But the 20% took me several hours (or days)  because I did not understand the problem. The worst thing is, when the same issue occurs again, I never remember it and has to Google it again.  This is because I never really understand what went wrong.A good example is Git, I had been using it for half a year without understanding the concept behind. When I see an error, a few seconds of Google will give me a “magic” command that solves everything. Of course, the magic doesn’t work everyday. And when it doesn’t, it usually causes me at least half a day.I learned this point from pair-programming with one of my colleagues. One moment when we ran into an error, he stopped and read it.  He REALLY read it before googling. When he saw something he doesn’t understand, he googled further and try to understand what really went wrong.

      Despite that, he usually finishes his stories quicker than others. He is, in my opinion, the most productive guy in our team. Of course, there are many factors. But one of the factor I guess is that he accumulated skill from really understanding of those errors. This skill allows him to avoid repeating the same mistake, and troubleshoot new errors more effectively.

    2. Ignore fundamental understanding of the language/framework – The ease of copy & paste makes it easy to “just do it” and move on. People start to think that they can use Angular after 30 mins tutorial. Yes, if you just want to make a Todo app. But to make a good design and avoid several hours of aimless debugging. You need to know more than that.A good example is when I first started was working in JavaScript. I didn’t know how variable scope work, so I accidentally override the global variable of the whole project.  I was stuck with another developer (who has equal knowledge of JS) figuring what went wrong for two days. We even thought that it’s because we saved the JS file in wrong encoding.Not understanding the fundamental will make you pay a lot in a long term. Invest your time to buy a good book that goes beyond simple tutorial & syntax. My small list of recommendation is:
      1. Java -> Effective Java
      2. JavaScript -> JavaScript: the Good Part (You can call me ‘old school’ guy, but read it)
      3. Angular -> Mastering AngularJS
    3. Copy & paste the code without understanding – There is a  saying that it takes you 200% of your knowledge to debug the code you write. So don’t do anything too clever, or you won’t be able to debug it.The same goes for copy & paste. If you don’t understand it, read it through first. Or you will pull your hair out when it breaks.I once found a bug that happens every 24th of December. When I asked other senior colleagues, they said that it happened in the last year too but no one found the root cause. Since there is almost no user in the system on that day, and they couldn’t reproduce it on 26th, no one bothers to fix it, meh…

      So I debugged it.

      I found a piece of code that has very strange variable names and different coding style. I didn’t understand what it does. So I pasted it on Google and found that piece of code on a blog with a very good explanation. It turns out that one of the variable that should be changed in that piece of code got the wrong values.

      Moral of the story? If you don’t understand how it works, don’t put it on your repository.

    4. Read everything – You understand it correctly. It is a pitfall to read everything.A lot of developers write blog, but not all of them are well-written. It is much faster to absorb the well-written material (like a good book) than reading multiple pieces of blogs written by different authors (with different style).I am not saying that you should unsubscribe those newsletter and RSS (if you still use it). But you need to be selective. Skim before you read it through.

      We have too much information today, most of them are duplicated. AngularJS tutorial is a very good example. And if you read a bad tutorial, bad practice will be with you for a long time.

In conclusion, don’t repeat my mistakes. Be better than me, be more efficient than me.

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: