Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!usc!rpi!zaphod.mps.ohio-state.edu!unix.cis.pitt.edu!dsinc!netnews.upenn.edu!platypus!robin.cs.uofs.edu!cml8 From: cml8@robin.cs.uofs.edu (Chris M. Little) Newsgroups: comp.lang.ada Subject: Pre-condition vs. Post-condition Keywords: pre-condition, post-condition, exception Message-ID: <344@platypus.uofs.edu> Date: 15 Mar 91 03:57:28 GMT Sender: news@platypus.uofs.edu Organization: Computer Science Dept., University of Scranton, PA. Lines: 19 Nntp-Posting-Host: robin.cs.uofs.edu Originator: cml8@robin.cs.uofs.edu Say we have a function CAPITAL which, given a country's name, returns its capital city. If the given country does not exist, an exception COUNTRY_ERROR 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? I brought this question up in class today and the outcome was a split decision. I think exception raising and/or handling is as valid an outcome of a function or procedure as any other outcome, so I'm tempted to cover the issue in the post-condition comment. My opponents believe that a function's pre-conditions should be the conditions under which it would complete "normally", that is, without any exceptions being raised. I'd appreciate any insight on the issue. E-mail please. Thanks. -- Chris Little, Graduate Asstistant - CML8@JAGUAR.UOFS.EDU (VMS) Department of Computing Sciences - CML8@SCRANTON.BITNET (VMS) University of Scranton, Pennsylvania. - CML8@ROBIN.CS.UOFS.EDU (UNIX)