NYCPHP Meetup

NYPHP.org

[nycphp-talk] Questions to ask at a job interview?

David Krings ramons at gmx.net
Sat Jul 7 20:05:12 EDT 2007


Ben Sgro (ProjectSkyLine) wrote:
> Hey again,
> 
> So, I had a string of interviews over the last two weeks.
> 
> I have just hired one candidate that I believe will be a good addition 
> to our company.
> 
> I ended up using the Joel Spolsky (or whoever coined this) question:
> 
> I have two variables and I want to switch their values.
> 
> Some candidates totaly froze, and other's got it quickly.

I'd use a third variable to keep a copy of one variable before basically 
making both the same first and then assigning the saved to copy to the 
originally uncopied variable.
Did I get hired?
No! Well, unless you are desparate...
Thanks to Google I now know the answer:
$x = $x xor $y;
$y = $x xor $y;
$x = $x xor $y;

I guess this shows that I have no formal programming training. Although, 
when would anyone want to switch variable values? Just use the one that 
already has the right value. Saves three lines of code! Same amount of 
lines is used with a helper variable, but the xor stuff uses less memory.

> I also showed some source code, a *small* 150L script, and asked them 
> what it did.
> 
> Not only was it commented, but the function & variable names are 
> extremely obvious.

Mind sharing that test script with me (us)? I simply want to know how 
good or bad I am.

> Some looked in awe and said, "this is a small script?" while some took a 
> few minutes
> and looked over the code, then attempted to explaint to me what it did.
> 

My record is currently at 761 lines for a script including comments and 
empty lines. I think 150 isn't huge.

> Overall, it was a great experiance. I look forward to finding new talent 
> to add to our growing
> company.
> 
> Thanks for all the responses and feedback!
> 
> - Ben

Thanks for asking and sharing with us. And for giving a PHP beginner an 
awesome opportunity to pick up some more skill. I wish I could spend 
more time on learning PHP.


David


David




More information about the talk mailing list