“The candidate has the right to ask clarifying questions”, or We bring the interviewer to a nervous breakdown

Published on May 26, 2016

“The candidate has the right to ask clarifying questions”, or We bring the interviewer to a nervous breakdown

Original author: David A. Pickett
  • Transfer
I recently read a blog post by a guy who complained that he was asked in an interview to write a function that should copy a file . No, I understand how you can vzestsya on such a task, but if in such a situation was I ... so I would come off in full:

Candidate : What exactly do you mean when you say “copy”?
Interviewer : Well ... create a new file whose contents are a copy of the contents of the original file.
Q : Do I need to copy the metadata about the time of creation and modification of the original file as well?
And : No, it is not necessary.
Q : Should the copy file have the same name as the original file?
And : no.
Q : Can a copy file have the same name as the original file?
And : Hmmm ... no.
K : Do I have to provide protection against attack through the substitution of letters with similar styles (for example, Turkish I )?
And : Do not worry about it.
TO: Should the copy file be in the same directory as the source file? I want to note that if so, then he probably cannot have the same name. Unless it comes to copying the file to itself (this is also an interesting question ...)
I : Yes.
Q : What about file attributes?
And : Copy them too.
Q : Should I modify the attributes of the source file? If the copy function that you ask me to write is part of a backup or archive operation, then I must reset the archive attribute of the source file.
And : No, leave them alone.
TO: You said that I should stupidly copy the attributes of the source file to the copy file. But if the archive attribute of the source file is reset, and I “stupidly copy” it to the destination file, then this may mislead the backup programs that can be used on this computer.
And : Just copy the attributes. I don’t care how the user organizes the backup there.
K : Well, it seems to me that this is not the most reasonable approach to developing software that people will still use, but since you insist so ...
And : ...
K : What about the “compressed” attribute? After all, it may turn out that the file system on which the destination directory is located does not support compression.
And : Make a copy uncompressed.
Q : Even if the source file is compressed and compression is supported in the destination directory?
And : YES.
K : What about the “encrypted” attribute? What if the source file is encrypted and encryption is not supported in the destination directory?
And : In this case, do not encrypt the copy.
K : I do not want to deviate from the topic, but it seems to me that such behavior will create a serious security hole. Especially if the file system on which we copy the file supports arbitrary attributes (directly or indirectly).
And : Listen, just copy the damn file!
Q : What about the file creator information?
And : I do not care!
Q : What about the file owner information?
And : I do not care!
K : What about access rights? Do I have to handle inherited and assigned rights differently?
And : To hell with the law!
Q : What OS should my function work on?
And : Windows XP.
K : Home, Pro, Media Center, or some combination thereof?
And : Pro.
Q : What service pack can I count on?
I : Service Pack 2.
Q : That is, I may not support previous levels of updates?
And : That's right.
Q : How will the name of the source file be transferred to me?
AND: As a parameter.
Q : Will it be transmitted as a string terminated by a zero byte, a string with a length, or as an object?
And : A string terminated with a null byte.
K : Should I consider passing a blank pointer to me?
And : no.
Q : Should I consider passing a blank line to me?
And : no.
Q : Should I consider the situation of passing me an incorrectly formed string (for example, without a terminating null byte)?
And : no.
K : What encoding is transmitted to me a name?
And : Unicode.
TO: Sorry, but Unicode is actually not an encoding. Unicode data must be in some specific encoding - for example, UTF-8, UCS-2, UTF-16 ...
I : Well, let it be UTF-8.
K : Well, but I dare to notice that then for transferring to the Windows API call I will have to transcode to UTF-16, and this is somewhat hemorrhoid ...
I : Then UTF-16!
K : What order of bytes ?
And : Rrrrr ... with what you want!
Q : Do you consider processing relative paths, or only absolute paths?
And : Only absolute.
K : Are there any peculiarities of the paths transmitted to me by which I should filter them?
AND: Not. Consider that the caller has already done this.
Q : How will the name of the destination file be generated (or transmitted)?

[... minutes passed, turning into hours ...]

Q : Do I have to support (or allow) asynchronous copying?
And : no.
Q : How should I report emergencies - exception or return code?
And : It makes no difference.
Q : Do I have to handle the exceptions coming from the functions I call, or just pass them to the code that called me?
And : Skip.
Q : What if the destination file already exists?
And : I swear by mom that no.
TO: That is, the calling program guarantees this?
And : That's it.
K : That is, if it still turns out that it already exists, it means that the guarantees are violated, and I should have brought the program down - something obviously went wrong, and you never know what else it will do there right now?
And : As you wish.
K : What about the secondary data streams of the file?
And : Yes, do what you want, damn you!
TO: Listen, it may seem to you that I am putting pressure on you, and I am very sorry - but it is extremely important for me to understand all the details of your task. Obviously, since you want me to write you a new function for copying a file — instead of using one of the many libraries and frameworks already implemented in various libraries — you have some very, very specific requirements that library functions do not satisfy , and I intend to draw these requirements from you. Of course, I can quickly sketch out something suitable, but I must say that we still have a whole bunch of incompletely clarified details ...
And : AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA !!!

The job is done .