Re: Terminating Application
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Fri, 12 Aug 2005 12:38:46 -0400
In one of the greater disasters I was involved in, and had to fix at great expense,
involved this sort of software. The client had chosen a database package from a
third-party vendoer. It did exit(0) in MS-DOS (always a mistake) and was "rewritten" to
Windows by changing it to ExitWindows() [I think; it has been over a decade] which exited
the program (I think ExitWindows had two modes, one of which shut down Windows and one of
which shut down the app). The disasters you describe ensued. The documentation sucked,
but their idea of what to do when invalid parameters were provided was to do a MessageBox
with a NULL window, so the message boxes popped up UNDER the application, and then they
didn't return an error code. When I called to complain,they paitently explained that "if
the index file is corrupted, we cannot continue the program", which is one of the more
incredibly STUPID excuses I've heard for poor programming in many, many years. It hadn't
occurred to them that they should return an error code under BOTH the above scenarios.
Totally clueless does not begin to describe their programmers. And they further told me
that some of the ghastly code I found was much beloved by their president, who had written
it, so even if I rewrote their handler to be sensible (which I had done), there was no way
they could accept this improved code because he would take it as a personal affront. I
went back to my client and we ditched the product. We had to rewrite the code to a new
third-party app, after I had wasted a fair amount of time trying to salvage it. I have
made sure that none of my clients in the intervening years ever chose that product. You
can't release a product to real users that will spontaneously exit, or pop up some
meaningless MessageBox.
Exiting a program is the last refuge of a lazy programmer. It takes WORK to do the job
right.
joe
On Fri, 12 Aug 2005 07:36:43 +1000, Ian Semmel <isemmel@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
wrote:
>Not only is it a bad idea, it can be a disastrous idea.
>
>I once inherited an extremely large realtime transaction-processing app (not
>windows) where the less than competent programmers just stopped the program (cf
>exit) at any point where they had coded themselves into a corner. The program
>would be chugging along and then collapso - the database would be compromised,
>transactions lost etc.
>
>A lot of new programmers do not consider error control when they design a
>system. Sure, it usually increases the complexity of the program by some
>exponential amount, but it is an integral part of any non-trivial solution.
>
>Joseph M. Newcomer wrote:
>> This is ALWAYS a bad idea. Only a user is permitted to terminate an application.
>> Violating this guideline only leads to user frustration. If something is so messed up the
>> program cannot continue, just disable all the menu items except File>Exit. If things are
>> getting that messed up, it is much better to fix the bugs that caused it. The fact that
>> WM_CLOSE will cause unhandled exceptions indicates that there are serious bugs in the
>> program and they MUST be fixed first. A well-written program can never get into the state
>> where continuing execution will result in unhandled exceptions. Fix the program first. In
>> forty years of programming, I have yet to see a situation in which exit(0) was a valid
>> response to what was ultimately an error in programming.
>> joe
>>
>> On Thu, 11 Aug 2005 13:49:04 +0430, "Mehran Ziadloo" <mehran20@xxxxxxxxxxx> wrote:
>>
>>
>>>Hi,
>>>Does anyone know how can I terminate an SDI application?
>>>To explain my situation, I'm trying to make an error handling mechanism and
>>>for some critical situations I have to terminate the whole application since
>>>it can't carry on anymore. I want to do this somehow that my classes
>>>destructors are called too. I have tried sending WM_CLOSE to the project's
>>>main window but it can't work out since I don't want my code execution flow
>>>to carry on after I sent this message (it makes unhandled exceptions). I
>>>would like something like exit(0) but it won't let the classes to do their
>>>destructing tasks.
>>>
>>>Does anyone have any idea?!
>>>
>>>Thanks,
>>>Mehran Ziadloo
>>>
>>
>>
>> Joseph M. Newcomer [MVP]
>> email: newcomer@xxxxxxxxxxxx
>> Web: http://www.flounder.com
>> MVP Tips: http://www.flounder.com/mvp_tips.htm
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- References:
- Terminating Application
- From: Mehran Ziadloo
- Re: Terminating Application
- From: Joseph M . Newcomer
- Re: Terminating Application
- From: Ian Semmel
- Terminating Application
- Prev by Date: Re: Adding a control and a background to a view, flickers
- Next by Date: Re: class derived from CFormView is not associated with dialog
- Previous by thread: Re: Terminating Application
- Next by thread: Re: Terminating Application
- Index(es):
Relevant Pages
|