Learning Best Programming Practices

Anyone can write code.

Well maybe thats not exactly true, but the point is that its not too hard to learn to code.  With sites like Codecademy and Udacity that teach many different programming languages as well as countless books, anyone who has a computer can learn to write programs.

If it so easy, why are programmers still in such high demand?  Because you can learn to program, but its really hard to become a great programmer.  Now bear with me for a second.  Of course you can learn everything about a language.  You can learn every keyword and every structure, but that means nothing if you can’t put it together into elegant code, which as it turns out, is really hard.

What it really comes down to is best programming practices.  You have to know them.  You have to use them.  And they’re hard to learn, especially by yourself.  An email I received from a professor at the beginning of this year is particularly indicative.  I had asked him to confirm the reading list for the semester so that I could get a head start and his response was:

I don’t want you to pick up too many bad habits before we begin!

So my question was always: How can you actually learn best programming practices?

I think I’ve figured out the answer.  There are 3 parts.

  1. Code review
    Letting great programmers critique your code is crucial. Sometimes it is as simple as you not knowing the most concise way to express a function, sometimes your logic is overly complicated.  In code, like in writing, the more you can simplify the better.  Having someone smarter than you review your code is a great way to see the flaws in how you write your own code.
  2. Pair programming
    Most of the times that I write inelegant code, I did not know of a better way to express it.  Working side by side with great programmers code is a great way to get inside their head and see how they approach problems, so you can compare this to your own approach.  A common scenario: “Whoa, I didn’t know you could do that like that!”  This is why I find pair programming to be so essential in improving my programming skill.
  3. Read elegant code
    I hate reading code.  Unlike in pair programming, you are looking at a finished product so you have to work very hard to deconstruct what the writer did.  However, reading elegant code is another great way, like pair programming, to learn things that you never knew were possible.  Once you figure out their logic, an elegant program can become a truly beautiful thing.  And then you know how to do it yourself next time around.

To make a long story short, becoming a great programmer is hard.  As Malcolm Gladwell says, it takes 10,000 hours to become a master at anything.  But if you follow the steps above, then you’ll be well on your way.

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s