豆瓣
扫码直接下载
在读 C# in a Nutshell
A consequence of the last point is that a client should never specifically “catch” a contract failure (the ContractException type, in fact, is internal to help enforce that principle). Instead, the client should call the target properly; if it fails, this indicates a bug that should be handled via your general exception backstop (which may include terminating the application). In other words, if you decide control-flow or do other things based on a precondition failure, it’s not really a contract because you can continue executing if it fails. This leads to the following advice when choosing between preconditions and throwing ordinary exceptions: • If failure always indicates a bug in the client, favor a precondition. • If failure indicates an abnormal condition, which may mean a bug in the client, throw a (catchable) exception instead.引自第538页
> 小橘子的所有笔记(100篇)
Conditional Compilation Versus Static Variable Flags The advantage of conditional compi...
表示其中内容是对原文的摘抄