Design by contract

Parent Previous Next

The component implements a design by-contract approach (Meyer, 1997). Methods in the component are written defining how we expect the environment to be before and after the method. These expectations are explicitly documented in the contract for the method and stated as assertions. The Design by Contract approach uses assertions as pre-conditions, post-conditions of methods, and class invariants, that is a class can be viewed as having a contract with its clients whereby the class guarantees to provide certain results (post-conditions of its methods) provided that the clients agree to satisfy certain requirements (pre-conditions of the class methods)

The design-by-contract approach implementation in the Diseases component includes an option for testing pre-conditions and post-conditions. The Estimate public method in the CRA.Diseases classes has two overloads, one of which allows testing pre-conditions and post-conditions. The test of pre-conditions is also always made (in both overloads) if an exception occurs, and the test result is shown in the error message box which is shown. If the pre-conditions are not respected, an exception may occur and an error message is shown, allowing continuing the client run.

Created with the Personal Edition of HelpNDoc: Full-featured Kindle eBooks generator