Data Structures Reference
It just amazes me that employers ask complicated CS-type questions for ordinary programming jobs. I&#x27;ve been out of the game for 20 years, and only did a few interviews anyway (as the interviewer), so what would I know! But FWIW, here&#x27;s the kind of question I&#x27;d ask.<p>&quot;I&#x27;m going to write a few lines of code on the whiteboard, tell me what you think of them.&quot; The code would be something like this:<p><pre><code>  If f(a,b) then
    X=6
  Elseif flag1 then
    X=8
  Endif
</code></pre>
My bet is, people would fall into one of three camps.<p>(1) The Bemused :-)<p>These people would have no idea what to say. That would be fine for a new developer, I&#x27;d just prod them in the right direction. For example, &quot;what do you think about inline constants?&quot; But if an experienced developer had nothing to say about that code, that would be a big red flag for me.<p>(2) The Defiant!<p>These folk would say, &quot;Gee that looks like very old code, I&#x27;m really more interested in functional languages, do you guys do any Haskell?&quot; This would also be a big red flag. First, he&#x27;s saying that he has no interest in my priorities as the interviewer, he&#x27;ll just ignore my questions and substitute his own. Second, he shows that he&#x27;s <i>not</i> really interested in code <i>as such</i>. It&#x27;s like a guy who says he likes cars, you take him around the corner and show him your one-off Porsche EVO hybrid, and he says &quot;Wow, an infinity pool! What did that cost?&quot; Fail.<p>(3) What I&#x27;d Expect<p>Here&#x27;s what I&#x27;d expect from an experienced developer, off the top of his&#x2F;her head:<p>&quot;Ok, I see in-line constants, and short variable and function names. Those are often undesirable, I can talk about that more if you like.<p>But the more interesting thing, is that X is only set if one of the two conditions is true. If neither condition is true, X does not get set to anything.<p>That might be a bug: the programmer meant to initialise X before the first test, but forgot. Or perhaps X is initialised much higher up. But if that was the case, I&#x27;d like to refactor the code to bring that initialisation closer to the code on the whiteboard; and&#x2F;or rename X to something less likely to be used by mistake in the middle; or at least, add a comment saying &quot;X initialised above&quot;. Or you could just add an else branch to the code on the whiteboard, to ensure that X gets set even when both conditions are false.<p>Another slight possibility is that when the first condition is false, the second condition is necessarily true, and the developer has written in the second condition as a form of comment. But in that case, I&#x27;d rather make it more explicit, by changing &quot;Elseif flag1 then&quot;, to &quot;Else &#x2F;* flag1 must be true *&#x2F;&quot;; or even asserting that, just to be sure.<p>Also, if the code in question is really complex, or just messy from years of maintenance, there might still be cases where X does not get set at all. In that case you could initialise it to an impossible value, say NULL, right at the start, then assert not null at the end. Or you could even re-write the code in truth table style, which I can talk about more if you&#x27;d like.&quot;<p>Me: &quot;The truth table approach sounds good. How would you do that? What kind of data structures would you use?&quot;<p>And so on.<p>Does everyone really use CS-type questions these days? Does anyone take the different approach displayed above?