Pro Tip: How to win the code sample game

Posted on: July 29th, 2009 by Rob Zienert

Right now there seems to be anything but a shortage of programming job applicants out there. For a company, that’s awesome, but for an applicant–it isn’t that wonderful of a situation. So I’m here for the first installation (and probably last) installation of: PRO TIPS: GET HIRED! In this episode, I will be covering how to win the game of code samples: because you will be asked for them.

When applying for a programming job, you will be asked to provide some sort of code sample. I’ve seen all kinds of code samples: some people send me like 20 lines of code whereas others send me full applications. So what do I look for? Probably the same as what everyone else asking for code samples looks for. Knowing these points will make you all the more prepared to potentially slay a code review.

  • Is it documented and to what extent? Good documentation is not always the what, but the why. Generally speaking, explaining that a conditional is checking for a function returning true or is equal to 42 is probably a waste of time. Explaining logic and your thought process so it can be followed and understood by yourself and others later on down the road is very important. Avoid situations like this.
  • Do you use the language’s tools properly? Show aptitude and depth of knowledge in the language you’re programming in. For example, in PHP, why write a regular expression for validating an email address when you could just use the filter_var function?
  • What’s your style? Is your code easy to read; could it be easily maintainable?
  • Is it straightforward and organized? Complex doesn’t have to be complicated. Do you abstract your code and break it down in a logical fashion?
  • How robust is it? Does the application expect and handle non-logical, idiotic conditions? The real world doesn’t care how your application is supposed to be used, it just does what it wants.
  • What are the programming interfaces? Is the code segmented well? Is it designed for reuse? Does it follow programming best practices?

Keep these in mind when you’re submitting your code wherever you apply and you’ll unquestionably be in a better place because of it. The functionality doesn’t necessarily need to be stunning, but showing that you know how to write good code will win the prize. Perhaps I will end up making a follow up post on how to win the interview game as well — or at least know how to come prepared for a typical (good) developer interview.

Now off to celebrate Mike Parler‘s birthday with a mid-week bar run.