A Philosophy of Software Design

Richard (Rikki) Andrew Cattermole richard at cattermole.co.nz
Sun May 24 05:02:08 UTC 2026


On 24/05/2026 4:27 PM, Richard (Rikki) Andrew Cattermole wrote:
> On 24/05/2026 4:10 PM, Walter Bright wrote:
>> Thanks. This is an interesting general purpose method.
>>
>> But the book suggests a different approach in the title - define them 
>> out of existence. I've also thought of various general replacement 
>> schemes for exceptions.
>>
>> The difficulty with exceptions is they are complicated. It's difficult 
>> to figure out what path the code execution goes through when there are 
>> various exceptions. The exception paths are also a rich source of bugs 
>> because they are untested and may never trigger.
> Where possible yes, you should remove the possibility of needing to 
> handle the error case.
> 
> But you can't always do this especially for a standard library.
> 
> It's far more on the rare side to have a problem where you can do it for 
> and there are enough cases even in UTF/Unicode to want it to produce an 
> error that you must handle.
> 
> An awful lot of application development is based upon the principle of 
> log + finalize outputs + kill task. And that requires some method of 
> unwinding, either implicitly via EH or explicitly via result types.
> 
> It is fairly well known and has been taught in software engineering for 
> a long time to avoid unnecessary logic like error handling here.
> 
> "Do any of your functions return error values? Is it possible to 
> redefine those functions to eliminate the error conditions? Remember 
> that when a function returns an error, that error must be handled - or 
> mishandled - at every point of call."  Writing Solid Code, Page 198, 
> Copyright 1993. https://www.amazon.com/Writing-Solid-Code-Microsoft- 
> Programming/dp/1556155514

Code Complete 2nd edition has three chapters about error handling, 
including one for exceptions and another for asserts.

This includes a brief discussion on each of: return a neutral value (not 
a character), error codes, log/error message, kill process. Copyright 
2004, Page 194, 
https://www.amazon.com/Code-Complete-Practical-Handbook-Construction/dp/0735619670

This is taught at tertiary education for programming. My copy was bought 
because it was required reading.

Note that CS courses may not cover this, but programming and software 
engineering qualifications should.



More information about the Digitalmars-d mailing list