From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,436ac666600e5ab3 X-Google-Attributes: gid103376,public From: randhol+nospam@pvv.org (Preben Randhol) Subject: Re: Exception Handling Date: 2000/06/01 Message-ID: #1/1 X-Deja-AN: 629811953 References: <3HCY4.29157$sB3.10828@news.indigo.ie> <3933DAF3.35F40B3A@utech.net> X-Complaints-To: usenet@itea.ntnu.no X-Trace: kopp.stud.ntnu.no 959853456 28223 129.241.83.82 (1 Jun 2000 09:57:36 GMT) Organization: Norwegian university of science and technology User-Agent: slrn/0.9.6.2 (Linux) NNTP-Posting-Date: 1 Jun 2000 09:57:36 GMT Newsgroups: comp.lang.ada Date: 2000-06-01T09:57:36+00:00 List-Id: On Tue, 30 May 2000 08:14:59 -0700, Jeffrey D. Cherry wrote: >Preben Randhol had a good response to this but I would like to add my 2 cents. >You could use an exception handler to trap this kind of input error but I >prefer to use exceptions for things that are a bit more unexpected. (Please >note that this is a personal bias.) Invalid input is what I would call an >expected error, so I apply validation criteria to the input before accepting >it. In your example, the only criteria is that the string be 8 characters In this example I agree with you. One slightly different angle though. Say you have made a program that expects the user to input a value. It could be any value so it should be possible to enter 2.3E-4 etc... Would it be OK to trap an erronious entry (like "2.3W-4") with an exception or would you make an extra check before trying to convert the string to a float (or the appropriate class). The reason I'm asking is that there seems to be two "camps" those who use exceptions extensivly and those who use it far less. I'm trying to find the border when and when not to use exceptions. -- Preben Randhol -- [randhol@pvv.org] -- "Det eneste trygge stedet i verden er inne i en fortelling." -- Athol Fugard