Re: Terminating Application



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
.



Relevant Pages

  • L2TP/IPSec certificate problem on Windows XP client
    ... We are unable to use a Windows XP VPN client to access a Windows 2000 ... The client machine certificate was issued through automatic ... In an attempt to fix this problem we have reissued ...
    (microsoft.public.win2000.security)
  • Re: Access 2000 Autonumber Corruption
    ... The latest Jet update should fix it. ... is to get each of the users to visit the Windows Update site and ... > client machines is replaced with XP/Pro/SP2 right when the server was also ... > corruption of the autonumber primary key field in one of the tables. ...
    (microsoft.public.data.ado)
  • Re: Reconnecting Remote Desktop on XP Pro
    ... With the new Windows Mobile 2003 OS there is a reconnect bug in the built-in TSC... ... > The other fix was to go to the system console and log in (and ... > stream and has disconnected the client. ... > The RDP protocol component WD detected an error in the protocol stream ...
    (microsoft.public.windowsxp.work_remotely)
  • Re: Troubles with setting OE6 as a default email client in XP
    ... I have problem with setting OE6 as a default email client. ... My windows is XP Professional SP1 ... I'll be happy if someone tells me how to fix it. ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)
  • RE: Printing from Win9x clients stops
    ... Open Server Management. ... then right-click the name of the computer running Windows Small Business ... >From the client computer: ... The Select Network Component Type ...
    (microsoft.public.windows.server.sbs)