Design by contract

Parent Previous Next

The component implements a design by-contract approach (Meyer, 1997). This 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 UNIMI.CropQuality includes an option for testing pre-conditions and post-conditions via a dedicated component. The Estimate public method in the UNIMI.CropQuality 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: Free help authoring tool