📜 ⬆️ ⬇️

"The candidate has the right to ask clarifying questions," or we are bringing the interviewer to a nervous breakdown

I recently read a blog post of a guy who complained that he was asked to write an interview function that he had to copy the file . No, I understand how you can embark on such a task, but if I had found myself in such a situation ... I would have come off in full:

Candidate : What exactly do you mean by saying “copy”?
Interviewer : Well ... create a new file, the contents of which is a copy of the contents of the source file.
Q : Do I also need to copy the metadata about the time of creation and modification of the original file?
And : No, not necessary.
Q : Should a copy file have the same name as the source file?
And : No.
Q : Can a copy file have the same name as the source file?
And : Hmmm ... no.
Q : Do I have to provide protection against attacks through the substitution of letters with similar outlines (for example, Turkish I )?
And : Do not worry about it.
Q : 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 we are talking about copying the file itself into itself (this is also an interesting question ...)
And : Yes.
Q : What about file attributes?
And : Copy them too.
Q : Should I modify the attributes of the source file? If the copy function you ask me to write is part of a backup or archive operation, then I need to reset the archive attribute of the source file.
And : No, leave them alone.
K : You said that I should stupidly copy the attributes of the source file to a copy file. But if the archive attribute of the source file is discarded, and I “stupidly copy it” to the destination file, this can be confusing for backup programs that can be used on this computer.
And : Just copy the attributes. I don't care how backups are organized by the user.
K : Well, it seems to me that this is not the most reasonable approach when developing software that people will still use, but since you insist so ...
And : ...
Q : What about the “compressed” attribute? After all, it may be 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, is compression supported in the destination directory?
And : YES.
Q : 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 a copy.
K : I do not want to deviate from the topic, but it seems to me that this behavior will create a serious security hole. Especially if the file system to 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 : Spit!
Q : What about the file owner information?
And : Spit!
K : What about access rights? Do I have to handle inherited and assigned rights differently?
And : To hell right!
K : On which OS should my function work?
And : Windows XP.
Q : Home, Pro, Media Center, or some combination of them?
And : Pro.
Q : What update pack can I expect?
And : Service Pack 2.
K : So I can 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 null byte, a string with a length, or as an object?
AND : A string terminated by a null byte.
K : Do I have to handle the situation of passing a null pointer to me?
And : No.
K : Do I have to give me a blank line?
And : No.
Q : Is there a situation with the transfer of an incorrectly formed string to me (for example, without the terminating zero byte)?
And : No.
K : In what encoding will the name given to me be?
And : Unicode.
K : Sorry, but Unicode is not a coding at all. Unicode data must be in a specific encoding - for example, UTF-8, UCS-2, UTF-16 ...
And : Okay, let it be UTF-8.
K : Well, but I dare to note that then to transfer to the Windows API call I will have to recode to UTF-16, and this is somewhat hemorrhoid ...
And : Then UTF-16!
Q : What is the byte order ?
And : Rrrrr ... with what you want!
Q : Should processing relative paths be considered, or only absolute ones?
And : Only absolute.
K : Are there any specific features of the paths that are transmitted to me by which I must filter them?
And : No. Consider that the caller has already done this.
Q : How will the destination file name be generated (or transmitted)?

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

Q : Should I support (or allow) asynchronous copying?
And : No.
Q : How should I report an emergency — an exception or a return code?
And : Without a difference.
Q : Do I have to handle exceptions that come from the functions I call, or just pass them to the code that caused me?
And : Skip it.
Q : What if the destination file already exists?
And : Mom swear no.
K : So the caller guarantees this?
And : Exactly.
K : That is, if it still turns out that it already exists, it means that the guarantees have been violated, and I should have brought down the program - something obviously went wrong, and you never know what else it will do there now?
And : As you wish.
Q : What about the secondary data streams of the file?
Q: Yes, do what you want, damn you!
K : Listen, it may seem to you that I am pressing you, and I am very sorry - but it is extremely important for me to clarify all the details of your task. Obviously, since you want me to write you a new file copying function, instead of using one of the many already implemented in all sorts of libraries and frameworks, then you have some very, very specific requirements that library functions do not satisfy and I intend to pull these demands out of you. Of course, I can already quickly sketch out something suitable, but I must note that we still have a whole bunch of not fully clarified details ...
And : AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA !!!
')
The deed is done .

Source: https://habr.com/ru/post/301924/


All Articles