On Wed, Dec 21, 2011 at 10:29 PM, <nore...@z505.com> wrote: > Marcos wrote: >> I use Exceptions to check the integrity of classes. I have one >> Exception for each class (E<class_name>), most of the time. > > > Another problem with errors is that sometimes it is hard for a class to > return errors. In procedural programming you can usually return an error > as a parameter but sometimes in class programming it is difficult for > classes to just return errors.
It's not difficult, but is boring have always a parameter or function return to return an error, and have to verify if error then... if not error... if error and error then... etc > Exceptions are an attempt to solve the problem, but imo this still doesn't > solve all problems and our applications are full of wild exceptions going > off despite our attempts to solve the problem.. because people fail to > check exceptions and catch them. usually I see code like this: > > Try > > Finally > > > You don't see as much Try Except, it's more Try Finally. People ignore the > exceptions because it's an accepted thing to do. Then the end user of the > application gets a strange exception message instead of a user friendly > one. For example, if a file is not found, I like to give a polite "Cannot > find file" message.. but usually in delphi apps and examples all over the > newsgroups you see just an EFileNotFound exception pop up instead. Or, > with StrToInt, a similar obscure exception message to the end user instead > of a more friendly one. I use many try-except in my own code but, most of the time, just catch my own exceptions because they are much more simpler to use. As I said before, I have Exceptions in only 2 levels: user and Lib (API, business rules, etc). The User exceptions always show a user friendly message (I think that you call Errors, right?). The Lib exceptions, for me, is the real Exception. So, If I call a routine but the app is not connected on DBMS... raise Exception; if a important property not been set... raise Exception; if a file has not found, this is not a exception, but if the app can not create a file... raise Exception. Marcos Douglas _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal