top | item 13724155

(no title)

scotttrinh | 9 years ago

When reading this, my immediate instinct was to say: "Easy!"

  import { flattenDeep } from 'lodash';

  const flat = flattenDeep([1,2[3], [4, [5,6]]);
Not sure why employers care about developers being able to write utility functions from scratch, when that is not (typically) the job developers are hired for.

Having said that, I lament the issues that the OP brought up: poor naming, unfamiliarity with their language's data structures, etc. Those are issues that will come up. Especially naming.

discuss

order

dpark|9 years ago

> Not sure why employers care about developers being able to write utility functions from scratch, when that is not (typically) the job developers are hired for.

Because of the reasons you listed in your next paragraph:

> poor naming, unfamiliarity with their language's data structures, etc. Those are issues that will come up. Especially naming.

No one actually wants a candidate to write "flatten". They want the candidate to demonstrate that they can work through a small problem and write something sane and functional. Utility functions tend to be small and reasonable to put together in about an hour.

With that said, I think this is a mediocre question because no one would create this list of lists-or-ints in Java. If presented well, the problem might be decent. If presented poorly, a lot of junior candidates would likely fail even if they're good candidates.

dwc|9 years ago

> Having said that, I lament the issues that the OP brought up: poor naming, unfamiliarity with their language's data structures, etc. Those are issues that will come up. Especially naming.

Indeed. And those things came up in writing a fairly simple utility function, so they're going to come up later in some large codebase.

While you're seldom hiring programmers to write utility functions like this, this kind of test shows whether the candidates have a basic familiarity with topics that will definitely come into play in their day-to-day work. I regularly run into "professionals" who can't structure their code in sensible ways, who don't even try to name things well, don't think about edge cases, etc. As it turns out, you don't want these people gluing together library calls either, because you'll end up with a mess on your hands.