+12  A: 

Interesting idea. However, what I don't like about this is that it gives the interviewee too little idea what they are actually expected to do. If you'd ask me this question:

How would you programmatically screw in a lightbulb?

in an interview, I would have no idea what you are talking about. Add the heightened nervousness of an interview situation, and you'll have perfectly capable candidates failing at this simply because they don't know what they're supposed to do.

In my opinion, you would at least need to add

In pseudo-code reflecting the process, how would you programmatically screw in a lightbulb?

For example: .... (and then some of the code you write above)

Pekka
I agree that the wording of the question definitely needs to change, and I would definitely expand on the question to explain what I'm looking for. Thank you for the insight.
Keith
@Keith you're welcome. I think the basic idea is very nice, and as long as you convey that this is a relaxed, creative exercise, it may work well. Maybe consider even showing the full example code for screwing in a lightbulb to give some guidance, and then ask for the pseudo-code for some other task.
Pekka
I agree. But why even bother using such an abstract concept when you could just as easily use something familiar and concrete?
Joe Philllips
@Joe I can see merit in this. Anything too familiar and concrete is going to invoke one's everyday programming patterns and solutions. Not that those patterns are bad, but for an exploratory measure, a creativity and (to some not too serious extent) personality test, pseudo-code and a non-serious b.s. task be more effective.
Pekka
@Pekka I suppose, if you're looking for how a person doesn't normally act. I guess I just don't see much value in the results
Joe Philllips
+5  A: 

None of those questions make sense from a software perspective. Perhaps you'd have better luck with something that is definitely rooted in software, even if it's too difficult to fully solve in the interview.

Alternatively, give the interviewee LightBulb and LightSocket classes with appropriate method signatures, and ask him what he would do with them. For example, how should he construct a new LightBulb? Would it be appropriate to use 'new' on it? Or should it come from a Factory of some sort? Should the LightSocket be a singleton?

Jonathan
That's a great idea, though I didn't want to give the methods/properties, as it seems that would force the interviewee into a "right answer" rather than having them think outside the box. This isn't as much of a programming question as it is a critical thinking/creativity/even personality test.
Keith
Maybe having the interviewee _write_ the `LightBulb` class (or at least outline it) would be better.
David Zaslavsky
@David Yes, you could certainly have the interviewee show you the steps necessary to create each of the individual objects, and then show you how he would use them.
Jonathan
+9  A: 

In the perversely overengineered Lightbulb framework:

class ScrewInLightBulb extends HomeMaintenance implements CornyJokes, Lighting {

    void doIt(Light light) throws 
    WrongSizeException, FellOffChairException, CantSeeException, 
    WrongWattageException, WifeYellingAtMeException, OldBulbBrokenException {

        LightBulb lightBulb = LightBulbFactory.getInstance(LightBulbTypes.BRIGHT);
        Chair chair = ChairSingleton.getInstance();
        try {
            chair.standOn();
        } catch(BrokenChairException) {
            goto Hospital;  
        }

        LightBulb oldBulb = light.unscrewBulb();
        try {
            oldBulb.discard(TrashSingleton.getSingletonInstance());
        } catch(IllegalWasteException) {
            oldBulb.tossOutWindow();
        }

        light.screwInNewBulb(lightBulb);
        light.setState(State.ON);
        Debug.assert(light.brightness != Brightness.DARK);
    }
}
dsimcha
Ahahahahaha! You, Sir, are very good at thinking of what could go wrong. Very nice.
Pekka
However, the final exception handler should not toss the bulb out the window, but call the landlord. I'm not kidding - I used to have a neighbour once who would call the landlord when she needed a light bulb replaced. :)
Pekka
don't toss the illegal waste out the window, hold for next trip to household hazardous waste collection site! geez...
Beth
The lightbulb will be garbage collected and you don't have to worry about it.
WW
+7  A: 

In pseudocode:

while( lightbulb not in socket ) {
  email [email protected] "Hey, put in a lightbulb"
  sleep 60
}

Lightbulbs are a hardware problem. Why would I, as a software developer, be asked to fix a hardware problem? :-)

CanSpice
[Hey! Listen!](http://www.youtube.com/watch?v=duRO3noyAKU)
jleedev
+1  A: 
<lightbulb onAttach="while($(this).attr('screwedIn')!=true){$(this).rotate(1/360);}"/>
FatherStorm
+3  A: 

Ahh... yes. Much like real programming, the candidate would be expected to craft a solution based on wholly inadequate requirements and a warped understanding of the capabilities of computer systems (which generally don't have manipulatable appendages).

Seriously, if the question took the form of a dialog where the candidate could ask clarifying questions, you might be able to gauge some analysis skills. Is the candidate thinking about things like socket size, wattage, voltage, etc.? Do you include a unit test to verify that the lamp lights afterwards?

If there's no interaction at all, however, I'd expect a fairly low hit rate of clever answers, and there's also the potential that an otherwise qualified candidate would leave your office believing that you're well and truly off your rocker.

Myself, I'd download a light-bulb library off codeplex and call LightBulbReplacer.ReplaceBulb();

D. Lambert
Based on your cynical response, I would not hire you. But you don't want to work for me anyway since I'm off my rocker, so we're both happy :)
Keith
@Keith: I'd hire him. At least I know he won't spend lots of time re-inventing the lightbulb and lightbulb-replacer, when an existing solution with code already exists. ;) You may have to make the question more specific to disallow people from importing a class that does all the work.
FrustratedWithFormsDesigner
@Frustrated: I liked his answer to the interview question, however I didn't like his answer to my question - I want to improve upon this in order to gauge the skills I listed above. Instead of saying my question had "wholly inadequate requirements", I wish instead he'd have helped me improve the actual requirements (i.e. the interview question).
Keith
Obviously, Keith, you missed the humor in my response... that's fine. I think it's fair, though, to assess the way a company approaches software based on a problem like that. If, as I said, you approach a problem like this as a conversation intended to discover *real* software requirements, then I think that's pretty healthy. On the other hand, if you toss a problem like this over the wall to someone without any benefit of clarifying questions, I'd want to steer clear.
D. Lambert
Thank you for clarifying. Humor and sarcasm are tough to pick up in text. Where's my sarcasm font already?! http://www.facebook.com/pages/We-Need-A-Sarcasm-Font/77506311431
Keith
Sign me up for the sarcasm font, too, Keith.
D. Lambert
A: 

A programmer would't screw in a lightbulb - it's a hardware problem. Call tech support!

Clicktricity
Tech support will only replace the bulb if it's a part of your computer.
FrustratedWithFormsDesigner
A: 

Or code your way out of a paper bag

Beth