G
Gianni Mariani
zeppe wrote:
....
.... ooh ... there is is. Unexpected behaviour. It is reasonable to
expect that any argument put on a command line is used and if it is not
used then it should be noted by the parser with at least a warning.
.... That is, if
If you were in an interview with me, you would get extra marks for being
thorough in explaining that silently ignoring command line arguments is
unexpected behaviour. It's a common sense thing.
Based on what I expect a command line parser to do.
.... You know nothing about this program, and for me it seems like it
YUP. That's right. I want the program to tell me how to use it unless
specified otherwise.
Not specified. You need to find out in the interview, the best way it
to specify it as an error and find out otherwise.
I have conducted many interviews and hired many programmers. I can tell
you that if you don't point them out, you're not doing as well as
someone who does. Wether you call them bugs or "different to what I
expect" is irrelevant.
I also often ask what are 2 problems when there are 4 or more. But then
again, I also don't hinge the entire interview on one bad question or
bad answer.
There are 3 stages to any inteview, the first is determining if the
candidate "can do the job" which is pretty easy. The next stage is
trying to figure out "will the cadidate do the job", which is much
tougher to answer, the final question is "can we handle this guy in our
team".
When you start pointing out nice things about how you try to do what is
expected (i.e. not dropping arguments silently) it starts to answer the
more important aspects of the interview.
....
What's wrong with ignoring arguments? For me, a bug is something that:
- makes the program crash
- doesn't make the program compile (but I would call it error as Ian
pointed out)
- makes the program act differently from what I want.
.... ooh ... there is is. Unexpected behaviour. It is reasonable to
expect that any argument put on a command line is used and if it is not
used then it should be noted by the parser with at least a warning.
.... That is, if
nobody tells me that the program shouldn't ignore input arguments, I
assume that this is legal. It may seem a rather rigid reasoning, but
this is an interview question, it's not a real program, in which case I
would ask what is the program for, before making assumptions.
If you were in an interview with me, you would get extra marks for being
thorough in explaining that silently ignoring command line arguments is
unexpected behaviour. It's a common sense thing.
Correct parsing should be:
if (argc < 2 )
{
std::cerr<<"Need ???NAME??? parameter to command "<<argv[0]<< "\n";
return 1;
}
you decided that there should be at least a parameter? and based on
what?
Based on what I expect a command line parser to do.
.... You know nothing about this program, and for me it seems like it
produces a result even without parameters. And, as far as we both know,
it may be the correct (expected) result.
if (argc > 2) {
std::cerr<<"too many parameters passed to command "<<argv[0]<<"\n";
return 1;
}
again. You are imposing restrictions on your own account.
YUP. That's right. I want the program to tell me how to use it unless
specified otherwise.
or probably a precondition on lookUpName, I would say...
Not specified. You need to find out in the interview, the best way it
to specify it as an error and find out otherwise.
You made good comments about pieces of code that are questionable, and
that's good. The only thing is that you weren't required to do so, but
just to find the errors.
That's IMHO, of course...
probably, if the interview context would have been appropriate, after
having pointer out the two error I'd have spent some words on the parts
of code that are "weak" in terms of behaviour, that are more or less the
ones that you described (but there would be a lot, for example that it's
so bad mixing char* and std::string, and that there is no reason not to
use only std::string, make the interfaces uniform, etc.).
I have conducted many interviews and hired many programmers. I can tell
you that if you don't point them out, you're not doing as well as
someone who does. Wether you call them bugs or "different to what I
expect" is irrelevant.
I also often ask what are 2 problems when there are 4 or more. But then
again, I also don't hinge the entire interview on one bad question or
bad answer.
There are 3 stages to any inteview, the first is determining if the
candidate "can do the job" which is pretty easy. The next stage is
trying to figure out "will the cadidate do the job", which is much
tougher to answer, the final question is "can we handle this guy in our
team".
When you start pointing out nice things about how you try to do what is
expected (i.e. not dropping arguments silently) it starts to answer the
more important aspects of the interview.