Stories
Slash Boxes
Comments

News for nerds, stuff that matters

Slashdot Log In

Log In

Create Account  |  Retrieve Password

Where Should I Get My Job Interview Code Samples?

Posted by Cliff on Thu Dec 14, 2006 01:59 AM
from the delivering-the-goods dept.
crlove asks: "I'm preparing for an upcoming job interview and my interviewer will want to see some code samples. Unfortunately, all of the coding I've done work-wise since college is not only proprietary, but often classified. To be honest, with long days at work and a busy life outside of it, I haven't had much time to code on my own. So, what should I show my interviewer? Should I start working up some code samples? If so, what would be considered sufficiently complex to take to an interview?"
+ -
story
This discussion has been archived. No new comments can be posted.
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More
Loading... please wait.
  • by Anonymous Coward on Thursday December 14 2006, @02:04AM (#17233168)
    If you dont have time, pay someone on rentacoder.com to write something for you.
  • by toddbu (748790) on Thursday December 14 2006, @02:05AM (#17233172)
    Anytime somebody tries to show me a code sample, the first thing I ask them is where they downloaded it from. Seriously, any employer that asks for a code sample has no clue what they're doing. They should put you at a whiteboard with a pen and have you write something on the fly.
    • by earnest murderer (888716) on Thursday December 14 2006, @02:19AM (#17233208)
      I agree.

      But since they asked, you might as well think big. [kernel.org]
    • Be honest! (Score:5, Informative)

      by TrisexualPuppy (976893) on Thursday December 14 2006, @02:20AM (#17233210)
      Tell your employer that it is all classified. There is really nothing that you can do about it. It would be a breach of contract and could leave you in legal jeopardy if you showed any of it to him...

      But the TSP has a solution. Tell him that you will code for him if he can give you a terse, yet challenging assignment. This will let him see what he wants to see (i.e., what he wants to test you on), and you're willing to take out a bit of your time just to show him that you're a hard worker. This strategy worked for me and landed me a job in the upper 80's!
      • by camperdave (969942) on Thursday December 14 2006, @03:15AM (#17233432) Journal
        FYI, most people call them the late 80's.
        • Re:Be honest! (Score:5, Insightful)

          by Ihlosi (895663) on Thursday December 14 2006, @10:25AM (#17235900)
          How is the interviewer to know that it is yours?



          Ask questions about it. They usually show very quickly if you understand the code. Then there are four possibilities:



          1. The code isn't yours and you don't understand it. Bad. You're out.

          2. The code is yours and you don't understand it. Also bad. Also out.

          3. The code is yours and you understand it. Good.

          4. The code isn't yours, and you understand it. Outstanding.

          • by UtucXul (658400) on Thursday December 14 2006, @01:14PM (#17239260) Homepage
            Ask questions about it. They usually show very quickly if you understand the code. Then there are four possibilities:
            1. The code isn't yours and you don't understand it. Bad. You're out.
            2. The code is yours and you don't understand it. Also bad. Also out.
            This is grossly unfair to Perl programmers. You don't really expect us to understand every regex we wrote months (or days) ago, do you?
            • Re:Be honest! (Score:4, Interesting)

              by djh101010 (656795) * on Thursday December 14 2006, @01:32PM (#17239592) Homepage Journal
              An interesting idea, but topics 1 thru 3 require complicity in grand theft. Topic number 4 is intrigging; Why not have the interviewer present code, and have the candidate describe it?

              That's the approach I take. "Here, what does this script do? Go into as much detail as you'd like." It's not so much what they say, but how they approach the problem that I'm interested in.
    • by eln (21727) on Thursday December 14 2006, @02:30AM (#17233244) Homepage
      I prefer to write a snippet of code on the board myself and ask the interviewee to interpret it. It can be difficult for people to come up with something on the fly during the pressure of an interview, but they should be able to follow the logic of a program written for them if they know the language (at least somewhat) and if they know anything about computational logic. I basically ask them to walk through the logic of whatever routine I put up on the board, and then ask them something specific about it (what will it print at the end, what is the value of variable x after execution, etc.).
    • by zullnero (833754) on Thursday December 14 2006, @02:52AM (#17233320) Homepage
      You know what works even better than a "lets stare at the poor guy as he tries to scribble some code clear enough for us to understand, then begin to nitpick like a bunch of chest thumping, thirtysomething, 'I'm an experienced coder and should be the manager'" orgy? Checking references. It doesn't take that long to do. If you can't get anyone, you contact the guy and ask them for someone else, and make sure it's either a college professor or the actual manager/supervisor. Doing that, in conjunction with sending the guy a short project and having him do it over the weekend, is as good as anything else.

      Seriously, how much of your project will this potential employee be doing on the whiteboard? NO one codes that way. Once in awhile, you stand in front of someone else and scribble out a flowchart or a diagram to clarify something. That's it. Just because the guy forgot a semicolon somewhere on a whiteboard scrawl doesn't mean he'll take 5 times longer to get something done working within an IDE that has built in context checking, has a help system loaded with code samples, and an internet connection that allows him to go out and find snippets made free to everyone when he's stuck on something.

      In fact, I'd greatly prefer employing someone that resourceful over someone who will sit there and bang their head over some problem for days or weeks. If you have someone who can find code, understand it well enough to incorporate it, and is detail oriented enough to refactor it clean, that's worth a heck of a lot more than some altruistic chump who thinks it's better to rewrite the wheel for everything. Resourceful people get the work done on time.

      There are occasionally situations where a coder has to solve a problem that hasn't been solved before, or where there isn't a solution readily available. However, those situations are really, in this day and age, few and far between...and if a coder can understand and incorporate a snippet of code into a project and make it work, he probably understands enough to write code on his own.
    • by quantaman (517394) on Thursday December 14 2006, @05:44AM (#17234004)

      Anytime somebody tries to show me a code sample, the first thing I ask them is where they downloaded it from. Seriously, any employer that asks for a code sample has no clue what they're doing. They should put you at a whiteboard with a pen and have you write something on the fly.
      A whiteboard is a lot different than a computer and all its associated resources. I've seen great coders freeze up when asked to code on a whiteboard and useless people come up with something great, especially when how clever they can be when writing an algorithm isn't what I'm interested in.

      Programs are large and very complicated systems, in my opinion a great programmer isn't someone who can write the fastest sort, it's the person with the skill and determination to quickly understand, and extend, large complicated programs.

      Thus when interviewing I like to have someone bring in a bit of their code. I then ask them to give an overview of what it does and how it works. I then ask them about how they would go about making a certain change in the requirements. What I'm looking for is how thoroughly they understand the design of the code and how well they can communicate that code to someone else. Even if they did download it they still have to really understand it and that's the hard part.
    • by bastia (145202) on Thursday December 14 2006, @08:17AM (#17234574)

      I disagree. I could be very useful in the interview process. We used it just to give us something very concrete and technical to discuss with the engineer. Throwing some people questions makes them very nervous, like they're being tested. Having them bring some of their own code to discuss makes most good engineers very relaxed. Here, they get to show their prospective employer something that they're reasonably happy with. If I ask any questions, they're usually very quick to answer. Now, I'm the "newbie" in the code, and they're just showing me around.

      I suppose that it depends why the potential employer wants it. Ask them. Many programmers just "steal" a page of code from some system they're working on even if it is proprietary. If you don't feel comfortable doing that, just work on something for a few hours. Whatever you have time to do. It might not have to be complete or very complex.

      When one of my managers started asking new candidates for code samples, it was actually quite useful in the interview process. I really didn't care whether they wrote it or downloaded it. We weren't looking for "do you know how to write code." We were really interested in hearing you talk about code. Hopefully, you sent us something you wrote. But it wasn't critical to the interview that you did.

      That is, you'd send us a page or two of code the day before the interview. It didn't even have to be in the programming language we were hiring you for (Java, C++, or Perl). One guy sent us some LISP code. Your interviewers would read over the code. Then, during the interview, we'd take out a copy of the code, ask you to give us an overview of what it does, and ask some more specific questions.

      Some examples: For a systems/tools job, one guy just pointed us to a little module in CPAN. The CPAN code had good PERLDOC comments, of course. It was packaged as a module. The guy could explain why he ended up writing it and talk about the code even though it had been a few years since he touched it. Another guy sent us code to a CGI script that he used on a personal web server to track some data between him and his friends. That code was okay, and the guy could explain what he was doing. But it was also a giant flat script. No subroutines. Almost no comments. Program logic and HTML output intervleaved in a somewhat confusing manner. The developer who sent us the CPAN code got the job. Not just on the basis of his code, but it just confirmed everything else we got out of the interviews.

      For another position, some developers sent us a page or two lifted from some of their Java code. Of course, in any real application, a page or two of code doesn't show you much. Still, one guy sent us code with what were almost certainly errors in it. Rather than telling the developer, "Um, this looks like an error," we just asked him to explain what the code was doing. I've rarely seen a candidate look so nervous. He didn't really seem to know what the code was doing. Either he didn't write the code, or he didn't really feel comfortable talking about code. Bzzt. Not someone we wanted on our team. In any case, if you're going to steal code, try to have good enough taste to steal good code. And if you're showing me code that you didn't write, at least take the time to read it and understand what it does.

      For the same job, another developer sent us code for a few methods. As soon as I started asking about the code, she looked so relaxed. Now we were just two engineers talking about code. She started sketching in the margins of the page to show a rough system architecture and where this code fit in. She explained a bit of the data flow and some use cases where the users interacted with the system. We talked about the data being passed in to one of the methods. At one point, she wanted to explain something, realized that she hadn't sent us that code, and sketched a rough version of the code on the back of one of the pages. Her quick version had a silly error. When I pointed it out, she just laughed and said, "Oh, right. It should be like this," and she fixed it. But she was eager to get back to explaining where that sketched code connected to the other code. That's the kind of developer we were looking for.

      • by Anonymous Coward on Thursday December 14 2006, @07:01AM (#17234294)

        That's a horrible idea. What the hell are they supposed to write? "Write down a linked list object, you have 30 seconds on the clock!"

        Haw! I just had a job interview yesterday and that's exactly what they asked me to do on the white board! Then they left me with my laptop and a coding assignment. In the past I had fantasized about doing that to people whom I had had to interview, so I didn't mind. After all, they want to make sure you can code.

        But, I've gotta say, I think this approach favors 1) people who've recently had programming classes where they cover general algorithms and data structures, 2) programmers who tend to think at an abstract level, whereas what I've found to be a more typically useful skill is the ability to translate business requirements (ie, what the customer wants) into code.

        • by Dun Malg (230075) on Thursday December 14 2006, @08:57AM (#17234848) Homepage

          But, I've gotta say, I think this approach favors ... programmers who tend to think at an abstract level, whereas what I've found to be a more typically useful skill is the ability to translate business requirements (ie, what the customer wants) into code.
          Christ Almighty, mod parent up so that more people might see and understand this! In my line of work I deal with many kinds of microcontroller based systems which are configured via serial cable with one-off PC-based "front ends". As a result, I end up working with all manner of shoddy crap cobbled together in Visual Basic by electronic engineers whose idea of a "logical interface" is (apparently) to model the GUI after the layout of the parts on the circuit board. They're all whizzes at coding the devices, but they can't seem to grasp that whole "usability" thing. To set a device to turn off at 9pm and turn on at 8am M-F, first you define an event type to 0800-2100 and remember the number the app assigns that event as. Then you go to the day-type table and define a day as consisting of one or more events (again this is given a number). Then you create a schedule type, which consists of 7 days, each assigned a number as defined by the day-type table. This schedule type (a number!) is then filled in in a box on the device configuration screen. None of these screens are easily accessible from one another, and each screen must be exited back to the top menu to get to the others. We quit buying from that vendor solely because they never improved their front end-- their controller hardware was outstanding. I actually got ahold of the engineer who wrote the software for another such product once, and he practically hung up on me when I offered to send him the improved front end *I* wrote to crib from-- or even steal, if he wanted. They still send out the latest updates to that turd, which I promptly integrate into my vastly superior in-house version. I'm not even bragging here. I'm no coding wizard, I'm a just a process engineer. My version is only just OK. The "official" version is simply horrifyingly bad. Imagine a window full of list boxes that can't be resized beyond 640x480 because all the objects are of fixed size. If you maximize the window, all the contents remain crammed into a 640x480 box in the center, surrounded by empty gray space Why? The engineer's excuse: "Because many customers are working at 640x480 resolution on older hardware". I tried to explain that list boxes can be resized to fit arbitrary window dimensions, but he just didn't get it.
  • by dcapel (913969) on Thursday December 14 2006, @02:06AM (#17233174) Homepage
    You can always "lift" some snippets from here. [thedailywtf.com]
  • find theirs (Score:5, Funny)

    by Amouth (879122) on Thursday December 14 2006, @02:06AM (#17233176)
    if your really good you get a hold of their code fix it and give it back to him in the interview - personaly i like the idea of handing the person being interviewed something from the cbfuscated C contest and ask them to take 5 min and tell me what it does - if they know you show them (seen it before) hire them... if they can manage to read it in 5 min and know what it does having never seen it before - hire them.. if they just look at you dumb.. send them home.

    but that is my personal view..
  • by creimer (824291) on Thursday December 14 2006, @02:21AM (#17233216) Homepage
    10 rem My first program... :P
    20 print "HELLO, WORLD!"
    30 goto 20
  • by MarcoAtWork (28889) on Thursday December 14 2006, @02:25AM (#17233234)
    ...they ought to give you a problem to solve and expect you to mail in the solution, something like 'ok, let's coordinate, sat morning at 8am I'll send you problem xyz by email, you mail back your code by 5pm, we'll discuss your solution during your follow up interview'.

    There's no way that a prospective employer can reasonably expect to be able to look at your current production code, and if they do and they expect you to bend the rules of your current NDAs I'm not sure it'd be somebody I'd want to work for anyways.
  • by bunbuntheminilop (935594) on Thursday December 14 2006, @03:06AM (#17233384)
    float InvSqrt (float x){
    float xhalf = 0.5f*x;
    int i = *(int*)
    i = 0x5f3759df - (i>>1);
    x = *(float*)
    x = x*(1.5f - xhalf*x*x);
    return x;
    }
  • by marktoml (48712) * <marktoml@hotmail.com> on Thursday December 14 2006, @08:51AM (#17234802) Homepage Journal
    However this is a good reason to have considered (at least considered!) doing a bit of work for an open source project. There are lots of them on SourceForge (and many other fine places) begging for help. A few bits added in make nice examples you can point to when asked for code samples. I know, it seems like a huge time investment that you don't have, but it really doesn't have to be. Further, every little bit helps the project guys.

  • by nblender (741424) on Thursday December 14 2006, @09:03AM (#17234922)
    In the time that it's going to take for you to read all of these responses, you could have sat down and written some code that will impress them. They're not looking for your magnum opus... They want to see stuff that shows you can understand a problem and translate your understanding into compilable syntax. In fact, they probably don't even care about compilable syntax. Think of a cute hack and write it instead of reading slashdot. Take it in and say "I can't show you any of the code I've written professionally, so I wrote this last night. You can confirm with google that I didn't download it from anywhere if you like, or you can ask me any questions about it and I'll be happy to answer them." Don't pick something related to the companies' core business. They understand their problems _way_better_ than you do. Second, decide whether you want to work for a company that quantifies you based on your code output. I'm a coder and I only spend about 10% of my work time actually writing production code. The rest is hacking test cases, prototyping, designing, staring at graphs, and attending team meetings.
    • Everyone seems to be in agreement except for a straggler a few posts down from here. Companies that ask for code samples are bozos and you don't want to work for them. But why?

      The answer has to do with corporate culture. Companies are made up of human beings and each one has different goals and needs and personalities. Some people get along famously while others will tear each other apart if left alone in the same room. Some people are very friendly and easy-going, others are hard-edged and driven. The type of people you hire will determine the culture of your company.

      Do people have fun at your company? Are they tired all the time? Do you have high rates of turnover? Do people think they work for the greatest company in the world? The worst? Do people dread meeting with other employees? Do people have a great time pounding out ideas together? Do people focus solely on their job position? Do people look at the company as a whole and see their role as a part of the greater whole? All these things are determined by the type of people you employ.

      The type of people you employ is determined by your interview process. If you make the interview process a relaxed one where the interviewee has the chance to articulate his thoughts well, you'll get one kind of employee. If you make the interview process a difficult, high pressure affair, you'll get another kind of employee. If you ask them to submit code samples, you'll get people who are either incredibly anal or look for shortcuts. If you ask them to code on a white board, you'll get people who can think on their feet.

      No one type of company works best for all situations. You wouldn't want cowboy coders in the bank software business. OTOH, you wouldn't want incredibly anal people working on next-generation UI stuff. But the type of people you hire is not only indicative of the culture of your company, it is a clue as to the personalities of the people working there.

      Another problem with the code sample thing is that it shows that the company values code quality over quality of character. My cousin BasementDweller78 is a wiz at coding. He can drop his pants and shit better code than I ever could. But he's a complete asshole. He isn't pleasant to be around. He's your prototypical computer geek. He's also the one that will get hired at a company that values code over people.

      So when some company asks for a code sample we all react with our gut and run far away. It's because we don't want to be around the type of people who would judge us on inanimate code. We'd rather be judged as humans and don't fear whiteboards nor do we lack confidence in our programming abilities. We are just a certain subset of all programmers. Those who value a pleasant working environment. Pleasant for us, that is.