App development, design, and promotion, tips, tricks and thoughts to help you make awesome apps.

Tuesday, February 12, 2008

Every developer should know to check that something exists before trying to use it.
Following on from the previous advice about not making assumptions about a file system. Be sure and extend your assumption checking beyond just the file system. Immediately that means files and their contents. But also think about: other programs; operating system components; peripheral devices; hardware components (ports, cards, etc.)

Why is this important?

Because at some point in the future, whatever your expecting to be there won't.
When that happens, one of the following is likely:

It will have no impact.

Part of the program won't work.

It will cause an error message to be displayed.

The program will crash.

The program will crash and will corrupt user data.

An important customer will be disappointed in your software and in you/your company.

You (or someone else in your company) will have to spend time with the user working out what went wrong and how to work around it.

You (or someone else in your company) will have to spend time updating the program so that it can deal with the missing element, to prevent customers having the same problem again in the future.

As a top class developer (or one in the making) I'm sure you can guess which are the most likley items in the above list and the ones you should focus on preventing.

What do you do once you know this?

Make sure you check!
You'll save yourself some support and your users some inconvenience by dealing with problems before they can happen.