developing application without exceptions

Is it possible to develop any application without exceptions? I don't want to try and catch exceptions and remove it.but I want to write codes which should never create exceptions is it possible?
Lets say that your program needs to write a file on the harddrive, but, the user has no space in his harddrive to do it?

You have to handle this in some manner, you can of course detect PRIOR to the action, if there is space and act accordingly. But, lets say that your clever user was copying data during the execution of the program, and between the test for avaiable space and the action of writing, space is now gone.

This would be an exception, wouldnt it?
Yes, real-time systems are expected to work as you described. However costs of creating such applications are higher in oredr of magnitude.
I really comes down to the scope of the application. At a certain point it becomes unfeasible to expect every component of a complex system to do it's job perfectly every time.

Exceptions aren't something you throw around in your program in place of good planning, in fact it's the exact opposite. You include an exception model in your program as a way of acknowledging that something that is not supposed happen is still possible. Let's expand on shoyoninja's example; let's say that are copying data from one disk to a backup. Obviously the data you are writing is more then the available RAM so you have to copy it to memory in individual chunks. If while writing the fourth chunk of data the program encounters the out of disk space error, how would you proceed? Would you keep trying to write the other 2,000 chunks of data and keep getting the same error like an idiot? Would you pretend to have completed successfully and lie to the user? Would you just quit out of the loop losing which file was written last?

Another thing that exceptions are useful for is preserving volatile data that would otherwise be lost if your program simply returned from a function or exited with an error code. For me, this is where I find them to be most useful but it's hard to come up with an example that isn't painfully specific.
Topic archived. No new replies allowed.