Ask HN: "a piece of code you're proud of" - what does it mean?
But I don't have such code. I've been programming for years, and there's no singular piece of a couple of lines that stands out. It's mostly boring, readable, well designed code that is maintainable. There's nothing sexy about that.
Sure, I'm proud of some large pieces of code. Thousands of lines that span an MVC architecture and three different platforms, for example. But the interviewer can't possible take the time to read it all and understand why I'm proud of it.
Should I whip up something incredibly complex, using the most esoteric syntax elements possible for optimal premature optimization, a nightmare to maintain, just to appease interviewers in this situation? What do you do HN?
[1]: http://en.wikipedia.org/wiki/Fast_inverse_square_root#Overview_of_the_code
42 comments
[ 3.9 ms ] story [ 98.8 ms ] threadThe interview question is designed to see whether you are the type of person that has lots of initiative, and would always walk the extra mile to improve an existing system, I suppose
Perhaps you could put together the most elegant solution (to your taste) of a well-known toy problem, and use that in such situations?
Online judges are eminently suited to this sort of task. They're a-dime-a-dozen these days. Heck, you'll find one in my profile!
Thanks for your suggestion of online judges. I didn't know there was such a market for code-judges, interesting!
[1]: http://en.wikipedia.org/wiki/Bron%E2%80%93Kerbosch_algorithm
http://en.wikipedia.org/wiki/Bron-Kerbosch_algorithm
Thanks.
My understanding was that such questions were more correctly phrased as "Tell us about a project you've worked on that you're proud of" (and I've had something like this a couple of times), in which case you briefly mention some details of a project that "spans an MVC architecture and three different platforms" or something else. If they want some specific code, you tell them you developed it at another company and cannot give any source, but you can describe the overall function of the software. (If it's open source, say you can link them to a repo.)
They probably want you to tell a story about the code and reveal loads of information about yourself, and it may help to do so, but you should only do that when you really know what type of story the hiring person wants to hear. I'd keep it strictly to the purpose of the software, and even something as innocent as "I made an abstraction that replaced 700 lines of Java with 40" can be taken many ways: "He's awesome, we want people who can make abstractions, let's hire him!"; "He coded 700 lines and didn't see the abstraction until then? He must suck."; "He's not afraid to make fairly large changes to teammates' code?[good or bad]"; "He thinks lines of code are awesome metrics?"; "Ew Java."
If they really, really want code, and it has to be a simple function or something, you could throw in a simple Scheme implementation of the map function and go off about map/reduce.
As you said, when they're asking to describe something you're proud of, like how Y-Combinator does it, it's a lot easier and relaxed.
The several ways of interpreting such an innocent lines are revealing, thanks for the heads-up!
I ask a question very similar to this when I interview, and I'm looking for applicants truly interested in the work they do and computer science. The occasion to apply an obscure algorithm, refactoring code to improve it dramatically, unusual elegance in a solution...
as an interviewer I'd be skeptical if the interviewee not only was secretive about his/her code, but had no pet projects or toy scripts lying about.
I think it's a great question because not only do you get a quick sense for how people code, but the response choice itself gives you some insight in to how people think and what gets them excited about hacking.
EX: I thought the twitter people where idiots so I codded up an outline for a solution that would fix their basic problem. I quickly got to single threaded code that was significantly faster than what they used and reasonable memory efficient so I stopped. However, it's not exactly a hard problem and it's not production worthy so I feel no reason to share it with other people.
One simple example, if I'm writing a utility to be used by me alone, I probably don't verify input. I don't do very good error handling (if it crashes who cares), etc, but if I were hiring the lack of any of these would be a serious red flag to me in any submitted code sample.
Of course there are larger personal projects were a little more care is taken, but it is a whole other level of polish that I put into professional work. I would be embarrassed to share my personal projects. That's probably actually a good sign because at least I know it should be better.
a) see if you're a decent programmer, ie. are there any obvious bugs/SQL injections/limitations, and
b) get you to talk about why you've coded something a particular way, what's good about it, etc, etc. Essentially an ice breaker question.
The other option is for me to try and find something that you've done online (eg. an open source project) and ask questions about that, but some people might think it creepy, so I try and get you to contribute code first.
I think you should give them code that tells a story. One with comments which explain why you did A and not B. Write an accompaniment to it "At first, I tried A. I researched and found out X, but...".
Few people can discover something as incredible as FFT, or FISR. Those are one-offs. It shows a lot if you worked hard at getting a solution to a problem and that you're proud of it; you didn't just copy-paste, you tried different ways of solving it and ended up with a solution that's, in the words of Goldilocks, just right.
Or that's what I'd send them at least.
Quite the contrary: I wouldn't hire someone whose code isn't like that.
a. ... that you can write code.
b. ... what your code looks like, to see your style.
c. ... how well your taste and judgement aligns with mine in the question of "good code".
I wouldn't want much, I wouldn't want anything world-shattering, I just want to see some code you think is clean and effective.
But that's me.
This does make sense if you'd ask him to explain it at the interview, but then the applicant can also give context and explain why he thinks it's good code.
Once they've done that we move on to discussing the code they sent.
All these things are purely to weed out the complete time-wasters. From the remainder, we then try to find someone who can design, code, document and collaborate.
1. You say "during the application process". Have you even met the hiring manager at this point? Worse yet, have you met anyone or are you just stuck in some automated process? Never forget that employment application is a two way street; you're evaluating them as much as they're evaluating you. They haven't earned the right to see your code yet.
2. This approach should be a red flag to any applicant. They want to see old code to evaluate you when they are 64 betters ways to do that? Something's fishy here - someone has no idea what they're doing.
3. Do not allow anyone to read your code out of context. You need to be there to explain the background, motivation, approach, and answer any questions. Cutting and pasting preempts yourself. Bring hard copy along only after the process has progressed far enough.
4. Only bad things can happen. This is like being the first the mention a number - you can't win. If someone wanted to hook up with you but asked for a dirty underwear sample first, would you give one? This is the same thing.
5. If your code is proprietary, who knows where it could end up? You may also be violating confidentiality agreements. Not worth it.
6. The employer-employee relationship is a never ending tension. You will always be "negotiating" money and working conditions, whether you realize it or not. Giving in to such an unreasonable request so early in your relationship marks you as a chump. You may never recover the equal footing you need (and deserve) in the ongoing relationship.
7. If they have a problem, move on. You're probably saving yourself a lot of trouble down the road.
You sound like a competent developer who should have no trouble finding a job without bending over. So don't.
[Aside: Because of this kind of thinking, I never give references before being hired. In essence, I'm telling the prospective employer, "You decide." They then have the right to rescind the offer if they don't like a reference.]
1. A chunk of my code is FOSS, sure they have earned the right to see it.
2. It's a red flag when an employer doesn't ask–shows me the hiring process may be more centered on solving questions/puzzles on the fly (which I'm very good at, so no bitterness-just that I'd rather work with people who love to and are talented at hacking which is not nec. the same thing).
3. Find a good coherent chunk, generate one, or put in something out of context but representative of your style as a hook to chat about the larger cooler project.
4. Not true at all, it could, in fact, land you they job.
5. You're right in that proprietary code is an issue, but I'd be skeptical of a candidate whose entire codebase was proprietary. Not even a single toy project or piece of home brewed code?
6. Taking a stand against an employer seeing you in action and getting a sense of your interests before employing you is not in your best interests while negotiating more money typically is. Remember you want to work with people equally competent and engaged as you are. You may be hot stuff, and the employer may get lucky buying your book without having seen a line of your great American novel, but it's easy to make mistakes when hiring and they are hard to correct.
7. That I do think is true–there are certainly employers out there which ask different questions, so finding the ones that are the best fits for your style and principles saves everyone time.
Of course, a tiny snippet of code would not be as useful.
You can't tell a decent coder from a great one with a snippet, but you can get a picture of their code and their tastes.
You'll also have an ice breaker if you want to interview them - just ask them about their code...
Seems like cargo cult interviewing. A company sees other companies doing the same things and decides "this must be a good thing to ask about!".
Things I will gladly do:
Things I strongly push: Things I will gladly do, but only after a job offer: Things I will never do:Most likely linking to a web site about a project you participated in of which you are proud would be more thorough.
If they're good employers, they're probably just looking for examples that you take pride in your work and that you can actually write code. Thus, my advice is to be honest. Even if the code isn't "sexy" or even that good. In fact, I've done well several times at this point of the application process simply by saying "This code sucks. But I'm proud of it anyway and here's why."