Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I wouldn't make them write code. Instead, I'd give them a couple of code snippets to review. </p> <p>For example, the first would be about <strong>design by contract</strong>: See if they know what preconditions, postconditions and invariants are. Do a couple of small mistakes, such as never initializing an integer field but asserting that it is >= 0 in the invariant, and see if they spot them.</p> <p>The second would be to give them bool <code>ContainedIn(char * inString)</code>. Implement it with a trivial loop. Then ask whether there are any mistakes. Of course, your code here does not <em>check for null</em> in the input parameter <code>inString</code> (even if the very previous question talked about preconditions!). Also, the loop finishes at character 0. Of course, the candidate should spot the possible problems and then insist on using <code>std::string</code> instead of this <code>char *</code> crap. It's important because if they do complain, you'll know that they won't add their own <code>char *</code>'s to new code.</p> <p>An alternative which addresses <strong>STL containers</strong>: give them a <code>std::vector&lt;int&gt;</code> and code which searches for prime numbers or counts the odd numbers or something. Make some small mistake. See if they find any issues and they understand the code. Ask in which situation a <code>std::set</code> would be better (when you are going to search elements quite systematically and original order of entrance doesn't matter.).</p> <p>Discuss everything live, letting them think a couple minutes. Capture the essence of what they say. Don't focus on "coverage" (how many things they spot) because some people may be stressed. Listen to what they actually say, and see if it makes any sense.</p> <p>I disagree with writing code in interviews. I'd never ask anyone to write code. I know my handwritten code would probably suck in a situation like that. Actually, I have seldom been asked to do so, but when I have, I haven't been hired.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload