A comparative study of Programming by Contract and Programming with Exceptions

Jimmy Byström, Leo Wentzel · 2003

This thesis is a discussion on and a comparison of two programming techniques used for error prevention and handling. The two techniques discussed and compared are programming by contract and programming with exceptions. The two techniques are defined and discussed in theory, and also evaluated and compared with the help of software metrics gathered from experiments. Experiments are conducted on two types of programs, a linked list program and a stack machine interpreter program. The linked list program was created for this specific thesis, whereas the interpreter program already existed. The linked list program was constructed in two versions, one according to programming by contract and one according to programming with exceptions. The interpreter was modified into one contract version and one exceptions version. Software metrics were collected from each version of the programs; metrics were also gathered from the original version of the interpreter. At the end of this thesis an evaluation of the experiments is presented. From the results of the experiments performed in this thesis no conclusive assessment could be drawn if one of the two programming techniques shows any significant advantage over the other.

Read the paper · More papers on PaperTik