enforce()? (what should be a contract)

Walter Bright newshound1 at digitalmars.com
Thu Jun 17 12:28:43 PDT 2010


Bruno Medeiros wrote:
> I would go further and state that anything outside the direct control of 
> a process (such as network state, disk state, OS state, other processes 
> behavior, user interaction, etc.) should be modeled as an error and not 
> a contract violation.
> Such externals errors may be a "bug" in the system as whole, but they 
> are not a bug in the particular process, and thus should not be modeled 
> as a contract violation.
> In other words, _contract violations should always be situations that 
> you can prevent by changing the code of the underlying process_. You 
> can't do that for network errors, disk state, etc.. But you can do that 
> for stuff like ensuring a variable is never null, an object in your 
> program is in some particular state at a particular point in execution, 
> etc.

That's a reasonable way of looking at it.


More information about the Digitalmars-d mailing list