Wednesday, January 23, 2008

EDSK ... not to make assumptions about a file system

Every developer should know not to make assumptions about a file system.

Don't assume that certain folders or drives will ever exist on the machine your software will be deployed on.

Also, don't assume you will have permission to access a location.

Why is this important?

If you assume a certain drive or folder will exist, or you have permission to access it but it doesn't or you don't. You software is likely to fail in unpredicted ways.

What do you do once you know this?

Test all assumptions. In code.
Want to install to the C drive? Test it exists first.
Want to write a file to a particular directory? Check it exists and you have permissions to write to it.


What do you think?
Is this something every developer should know? Have you say in the comments.

0 comments:

Post a Comment

I get a lot of comment spam :( - moderation may take a while.