Snappy Answers to Stupid Programming Questions

Here's a not-so-gentle reminder from David Pickett that some programming interview questions – in this case, "how would you write a routine to copy a file?" – are, well, stupid*:

Q. What about the attributes?
A. Make the attributes the same.

Q. Should I modify the attributes of the source file? If this file copy is part of a backup or archive operation, it'd probably be a mistake to leave the 'Archive' attribute on.
A. No, leave them as-is.

Q. What if the source file has the Archive attribute off? If I make it off on the new file as well, it could screw up the user's backup software.
A. Just make it the same. I don't care about the user's backup software.

Q. Well, I'm not sure that's the best approach to take when thinking about designing software FOR users, but if you say so.
A. ...

Q. What about compression? It's a file attribute, but the copy destination may not support compression.
A. Don't compress the copy.

Q. Even if the source is compressed, and the destination supports compression?
A. YES.

Q. What about encryption? What if the source file is encrypted, but the destination does not support encryption?
A. Don't encrypt the copy if the destination doesn't support it.

Q. Mmmmm, sorry, don't mean to digress, but … that could be a serious security hole. Especially if wherever this file copy function ends up supports arbitrary parameters (directly or indirectly).
A. Look, just copy the damn file.

"How would you write a routine to copy a file" is just another interview riddle; it doesn't deserve a face value response. David's answers are even better-- they implode the question under its own weight.

Al Jaffee's Snappy Answers to Stupid Questions book cover

The only rational answer to "how would you write a routine to copy a file?" is another question: why would any competent programmer ever write a file copy routine?

The last time I checked, moving mount Fuji wasn't a part of our business plan, either.

* With apologies to Al Jaffee.

Read more

Stay Gold, America

We are at an unprecedented point in American history, and I'm concerned we may lose sight of the American Dream.

By Jeff Atwood · · Comments

The Great Filter Comes For Us All

With a 13 billion year head start on evolution, why haven't any other forms of life in the universe contacted us by now? (Arrival is a fantastic movie. Watch it, but don't stop there - read the Story of Your Life novella it was based on

By Jeff Atwood · · Comments

I Fight For The Users

If you haven't been able to keep up with my blistering pace of one blog post per year, I don't blame you. There's a lot going on right now. It's a busy time. But let's pause and take a moment

By Jeff Atwood · · Comments

The 2030 Self-Driving Car Bet

It's my honor to announce that John Carmack and I have initiated a friendly bet of $10,000* to the 501(c)(3) charity of the winner’s choice: By January 1st, 2030, completely autonomous self-driving cars meeting SAE J3016 level 5 will be commercially available for passenger

By Jeff Atwood · · Comments