[UPHPU] Coding Correctness
php at ericfaerber.com
Thu Oct 9 19:16:26 MDT 2008
Justin Giboney wrote:
> I went to a job interview last Thursday in which I felt I did well except
> for one question that he asked me. He asked me to create a PHP function that
> takes an input and outputs even if a number is even and odd if a number is
> odd.* Below are the function that I wrote in the interview, and the function
> that I would have liked to have written in the interview. Now here are some
> questions for you:
> 1) is there a big difference in the two functions?
> 2) if you could grade these on completeness, how would you score them?
> 3) what would be your perfect answer?
IMO the first function is better. It does exactly what he wanted without
being complex. To make it better all I would add is a comment that says
something along the lines of "This function assumes $number is an integer".
More information about the UPHPU