Applying for jobs - places are asking for "code samples" - ??

KevySaysBeNice

[H]ard|Gawd
Joined
Dec 7, 2001
Messages
1,452
Hopefully this doesn't paint me as somebody totally unexperienced, but in both of my programming gigs I've had outside of college, I've never been asked to submit a "code sample" - so I'm not sure what I should do.

I have plenty of code that I've written, but lately I've been doing a lot of web development which means not any huge crazy 10000 line applications or anything. Loops, some jQuery, some JS, PHP, etc.

I can't think of any "code samples" that are particularly impressive by themselves...
 

PTNL

Supreme [H]ardness
Joined
Jan 2, 2005
Messages
4,199
Maybe not impressive, but consider that a few code samples does provide:
- conversation starter (likely after the initial tech screening) to test your communication skills
- examples of your coding habits
- insight to your thought processes that went into why you chose the implemented solution (versus another you had considered or something the interviewer may consider a possibility)
- project size/scope discussions, and your role in the project
 
Last edited:

maw

Supreme [H]ardness
Joined
Sep 27, 2000
Messages
4,135
code samples tell a lot about your coding style and experience.

For example, in ASP.NET/C# there are probably six different ways to write a simple page that selects some data from a DB and display it in a table based on some user input. They'll probably look at how you built your query, do you use parametrized queries? stored procs? inline SQL? are you sanitizing submitted data? are you using proper HTML markup for your pages? CSS? are you using or not using web controls (and if so, which ones)? are you doing any actual hand coding or are you relying entirely on the drag & drop widgets? etc..etc...

The same can be said for PHP or any other language for that matter.
 

Whatsisname

[H]F Junkie
Joined
Nov 15, 2000
Messages
10,202
Find some old ACM Programming contest questions, and answer those. Those make good code samples.
 
Joined
Feb 6, 2005
Messages
780
Choose stuff with:

-Commenting
-Formatting
-Consistency

Also if you've used any OOP in your web stuff, which shouldn't be too huge, I think that'd show that you look ahead (dynamic vs. linear programming).

Think about how you examine rhetoric in a literature piece. Use those strategies and think about how they will read your code.
 

KevySaysBeNice

[H]ard|Gawd
Joined
Dec 7, 2001
Messages
1,452
Thanks for the tips/advice everybody!

So, should I send an entire project? Or a page?

The problem is I work in two extremes:

at home, for "fun", I work on projects that normally involve some fairly basic code. I use an MVC framework for most of my PHP, so most of my PHP is pretty simple really. It's clean, but again it's super simple in reality. CodeIgniter does all of the heavy lifting.

At work (eCommerce store) I work with a team of two other developers, and we work on a codebase that's been around for a few years before I even started working here. So while I have written new pages, it's rare that everything on a page is my code, and the large majority of my work has been fixing/changing functions, dubugging terribly written JS, etc. The database access class we use pre-dates me, and even the majority of the stored procedures that we use are modified mainly for maintainance. I'd have to hand over 10 different classes.
 

PTNL

Supreme [H]ardness
Joined
Jan 2, 2005
Messages
4,199
I'd send enough that highlights the reasons and comments shared above for what (ie: implied assumptions that) the interviewer is looking for. You can talk about how what you send fits into the big picture; the interview won't have time for a full project analysis and teardown. They just want to see more than a gist.
 
Last edited:

Khanmots

Gawd
Joined
May 12, 2007
Messages
905
I'll simply note that from a legal standpoint I wouldn't include anything you wrote for work as that's not your code to distribute.
 

ameoba

Supreme [H]ardness
Joined
Jan 9, 2001
Messages
6,413
Find some old ACM Programming contest questions, and answer those. Those make good code samples.

Project Euler is also pretty good. Most of the solutions are small & the nature of the problems means that you'll be emphasizing problem solving skills rather than coding style but...


Coding samples are good but, unless you're just out of school or deeply involved in some OSS/personal projects, a lot of people won't have them. I think a better solution, for a hiring manager, would be to give a little 'homework' assignment - a simple problem that would probably take 1-2hr to code up.
 

Red Squirrel

[H]F Junkie
Joined
Nov 29, 2009
Messages
9,211
If you don't have one already, start a personal project involving a large scale app with 100k's of lines of code. Makes sure it is all very well structured and pretty much bug/exploit free, and a useful app. Maybe a SAP killer app or something.

Everyone is outsourcing programming these days, so you want to be able to REALLY impress them, since their plan B is probably to outsource.
 

BDV

[H]ard|Gawd
Joined
Dec 12, 2006
Messages
1,957
If they ask me for "code samples" they can go screw themselves.


Fortunately I'm past applying for positions which require these and my products speak for themselves :D
 

Whatsisname

[H]F Junkie
Joined
Nov 15, 2000
Messages
10,202
Did they ask you to write code before hiring?

Would you hire a juggler without having him juggle first?

If they ask me for "code samples" they can go screw themselves.


Fortunately I'm past applying for positions which require these and my products speak for themselves :D
 

BDV

[H]ard|Gawd
Joined
Dec 12, 2006
Messages
1,957
Did they ask you to write code before hiring?

Would you hire a juggler without having him juggle first?

I had to write code for my first position out of univ. and never again.


Sure. If experience, project examples and interview went fine.... I wouldn't hire some guy from the street taking his word for being a good coder.

I really could not care less if they use tabs or spaces for their code formatting...
 

mikeblas

[H]ard|DCer of the Month - May 2006
Joined
Jun 26, 2004
Messages
12,776
We never ask for code samples; they tell us nothing about your coding style and experience. They let us know that you can copy and paste, and that's about it. We don't know how long it took you to write the code you send, if you wrote it yourself or it was someone else's, or if it was a part of a team project. We don't know if it was traumatic and difficult for you, if you just sat down and coded it straight up.

Worse yet, there's no good way to express the ability to architect code in a small sample. Because of this, requiring a code sample actually limits the type of candidate which might apply for a job. Further, there's legal issues. If we see the code you've written, it poisons us for some intellectual property isuses.

Did they ask you to write code before hiring?
Asking for code in an interview is far more appropriate; it circumvents almost all of the problems outlined above.
 

BillLeeLee

[H]F Junkie
Joined
Jul 2, 2003
Messages
13,486
I've been asked to code during phone interviews, and then in person, but have never been asked to provide samples up front. mikeblas makes a good point that doing that is not really a good indicator of one's ability to write and design code.

However, on phone interviews, it's always nerve wracking for them to say "Okay, let's go to this website so I can watch you code in real time." I have no problems writing code in an in-person interview, but there's just something about the facelessness and impersonal nature of doing live coding over the internet that just makes me have a mild panic attack. If you can't imagine it, here's an example: writing code in Google Wave and everyone sees what you're typing, what you're deleting, and all things in between as you do it.
 
Joined
Oct 26, 2006
Messages
744
I don't think a snippet of code, or a class or two, makes sense. However, if you've got an open source project which you've completely designed and implemented on Sourceforge or Google Code, that would be a good sample.
 

Red Squirrel

[H]F Junkie
Joined
Nov 29, 2009
Messages
9,211
I would hate live coding. I'm guessing they probably would not allow access to outside resources either. Just because you can't remember all the arguments of some function or whether they capitalized the first letter, does not mean you can't code. As a coder, being able to lookup stuff is crucial. This is actually why I hated school, we used to have to learn stuff by heart that in the real world, it makes more sense to just look up. Einstein had it right when he said "Never memorize what you can look up in books.". (keeping in mind when he wrote that, there was no internet)
 

maw

Supreme [H]ardness
Joined
Sep 27, 2000
Messages
4,135
I would hate live coding. I'm guessing they probably would not allow access to outside resources either. Just because you can't remember all the arguments of some function or whether they capitalized the first letter, does not mean you can't code....

I think any competent interviewer would understand and allow some leeway in that regard.
 

BillLeeLee

[H]F Junkie
Joined
Jul 2, 2003
Messages
13,486
I would hate live coding. I'm guessing they probably would not allow access to outside resources either. Just because you can't remember all the arguments of some function or whether they capitalized the first letter, does not mean you can't code. As a coder, being able to lookup stuff is crucial. This is actually why I hated school, we used to have to learn stuff by heart that in the real world, it makes more sense to just look up. Einstein had it right when he said "Never memorize what you can look up in books.". (keeping in mind when he wrote that, there was no internet)

The questions are typically more of "Here's a function we want you to write", and my interviewers have been generous with the fact that syntax or function arguments might be off. They wanted to see that I could actually write code and solve a problem with it, even if I missed a ';' or something. The real point is to keep talking, talk it through, your interviewer is trying to see if you can code, and also your thought process when you're asked to solve a problem, no matter how trivial.

In school almost everything we were tested on was theoretical, I almost never wrote code on an exam, and if I did, no one slammed me because I forgot some argument, because in school we were never allowed to use normally predefined functions anyway. :p :eek:
 
Top