comp.lang.ada
 help / color / mirror / Atom feed
From: knoll@coopn1.csc.ti.com (Ed Knoll @(719)593-5182)
Subject: RE: pre-condition vs post-condition
Date: 16 Mar 91 14:42:57 GMT	[thread overview]
Message-ID: <9103161442.AA15853@tilde> (raw)


>is raised.  Should the given country's presence be listed as a pre-condition
>for this function, or should its absense (it doesn't exist) and the raising
>of COUNTRY_ERROR be listed as a post-condition?

The answer is that neither post- or pre-condition is best, or rather both 
are based on the context of the situation.  How is the module being 
used?  What is the scope of the module?  Is it a reusable component?  
Does it interface with other modules in a known or "friendly" environment, 
or is it interfacing/interacting with external subsystems of unknown quality?

For a module which is part of the internal workings of a subsystem, a 
pre-condition would be more reasonable.  It makes more sense for every
module to insure that the data they pass on/generate is always correct.
If modules of the same working subsystem have to verify all inputs, too 
much overhead/coupling is incurred.

However, if a module is interacting with components external to a subsystem
and these components are unknown/unrelated to the local subsystem, it makes
more sense to do the error checking and to document the exceptions as part of 
the behavior of the subsystem.  Well behaved subsystems under valid and 
invalid stimulus will be more portable/reusable then subsystems which react 
unpredictably in the presence of invalid stimulus.

Ed Knoll
Texas Instruments
knoll@coopn1.csc.ti.com

             reply	other threads:[~1991-03-16 14:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1991-03-16 14:42 Ed Knoll @(719)593-5182 [this message]
  -- strict thread matches above, loose matches on Subject: below --
1991-03-18 17:57 Pre-condition vs Post-condition Neil Webre
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox