我更喜欢错误管理的“rc”错误代码返回样式。我同意这带来的挑战可以通过 throw-catch 更好地解决,但是,我仍然觉得我没有以干净和可维护的风格进行设计和实施。因此,我正在寻找一本讨论该模式的好书,而不仅仅是一本参考书。
参考书目也可以...
我发现以下答案的摘录“敏捷程序员的实践”特别引人注目:
**Keeping Your Balance**
• Determining who is responsible for handling an exception is part of design.
• Not all situations are exceptional.
• Report an exception that has meaning in the context of this code. A NullPointerException is pretty but just as useless as the null object described earlier.
• If the code writes a running debug log, issue a log message when an exception is caught or thrown; this will make tracking them down much easier.
• Checked exceptions can be onerous to work with. No one wants to call a method that throws thirty-one different checked exceptions. That’s a design error: fix it, don’t patch over it.
• Propagate what you can’t handle.