views:

565

answers:

8

No, this isn't a 'plz send me teh codez' question, before you start!

I've been looking for a new job lately, and I've found that a lot of advertisements (well, the ones for the places that I wouldn't mind working at), ask for code samples in addition to a CV. I've spent some time thinking about this, as my day job is writing PHP/HTML/CSS CRUD apps and most of the code I've written is fairly mundane. I don't really have anything I can point to that is particularly impressive or interesting in and of itself. Maybe that means I'm a terrible developer or something, I don't know.

My question is - what type of thing would you write for as a sample of your work? Would you bother writing something special at all, or just submit something mundane you've already written like I mentioned? Is there anywhere I can get ideas for something interesting to do? I was thinking I might solve one of the harder Project Euler problems, but (a) that doesn't really relate to writing CRUD apps and (b) PHP kinda sucks for Project Euler.

Thanks :)

A: 

Choose a piece of code you've written that solved a non-trivial or interesting problem. Describe the problem you faced, and your subsequent approach to solving it in code.

Don't send something 'mundane'.

Galwegian
A: 

Write a personal page oriented to show your professional profile, with a backend. Make it the prettiest you can, and open the code. Include this website in your CV, and put a link in it to download the code.

More complex, write a system to install a temporary version of this website. Then, your interviewer could try your application.

ARemesal
+1  A: 

You have to ask yourself what kind of thing do you think your potential employers are looking for in the code sample. In my experience (of interviewing candidates) given a code sample I look for a good clean coding style, sensible names for functions/variables and something that demonstrates a reasonable understanding of the language (clever use of a particular feature or something that shows more advanced knowledge). I don't actually look too closely at what the code does - we test for that separately. However, you should be prepared to talk about the code, explain why you took a particular approach and how if you has more time you would like to expand or improve on what you did.

I suggest you pick a reasonably small and fun problem and tackle that.

Gwaredd
A: 

I think it is the best to send a sample of code from a real application you wrote, not something you made up for the interview. The code is supposed to give the interviewers some insights in how you program, and will work as a conversation starter - they will possibly fire questions about technical details, your opinion on certain matters, design decisions, etc. If you write something specifically for the interview, that will probably not work well. At least it will send the message that the code you write normally isn't worth sending over - which is probably quite the opposite from what you want.

So pick a piece of code that is well written and clear. If that's (part of) a simple CRUD-application, that's OK, because that's what you've been building. There don't need to be any spectacular algorithms in there or anything - that's not what they want to know. If they do, they'll ask for that (in the interview).

Jeroen Heijmans
A: 

Whatever code you send, make sure it has:

  1. Written description of why, how, when, what-for etc.
  2. Unit tests.
Ali A
A: 

See if you can't show off the structure of your PHP applications. Using a relatively unstructured language like PHP to put together an MVC design, etc might be pretty impressive to some employers.

Stefan Mai
A: 

I got my present job partly because I had (and still have) a programming weblog. The CTO noticed that one of the first postings was about SNOBOL (one of his favourite languages) and told the CEO that they had to employ me.

boost
+2  A: 

This is a great question! I started to answer it here and found it so interesting that I decided to write a whole blog post on the topic, which you can find here: "The Programmer’s Guide to Getting Hired: The Code Sample".

Here is the quick and dirty version:

  1. Code samples are more frequently used to filter people out than to assess any programming skill. It is just too hard to tell much more than basic competency in such a small amount of work. As such, I suggest keeping it simple and short so you don't give yourself enough rope to hang yourself with. People are opinionated about code and generally hate anything that was written by someone else, so don't give them a lot of nitpick fodder.
  2. Whatever you submit, be prepared to defend it, optimize it, and talk intelligently about any technology you used.
  3. I suggest (for reasons I explain in the article) that you write a fresh code sample and don't submit something you wrote for work.
  4. Readability and accuracy are the most important factors. Even more than what the code actually does.
  5. If you want to impress, don't use clever tricks. It is better to show off which technologies you know how to use correctly and your ability to apply good technique (Design patterns, OOP, etc) than how well you can game a compiler.
JohnFx