CSE2305 - Object-Oriented Software Engineering
exercises

CSE2305
Object-Oriented Software Engineering

Exercise 5: Testing and Debugging

This exercise is designed to reinforce the concepts discussed in the lectures. There are no marks for completing this exercise, however your attendance at tutorials and successful completion is officially recorded and may be used as a positive adjunct to assessment in special circumstances.

You are strongly advised to compete the exercise as it will help you with the concepts discussed in lectures and assist you in successfully completing the practical work. Exercises often mysteriously reappear as exam questions.


Topic: Use metrics and profiles to analyse and improve the Rational class.

Purpose: a chance to gain experience with code analysis and optimisations.

Background: Download the solution to the previous exercise — the Rational class. Note that the solution includes a new Tester class, which will be used to generate data for the profiler to profile.

You are required to use object-oriented metrics and a profiler to optimise and test correctness for the Rational class.

How to Proceed:

  1. For the Rational class provide the following metrics:
    1. The C&K Weighted Methods per Class, WMC (using cyclomatic complexity to measure the complexity of each method).
    2. Lorenz & Kidd's Class Size, CS metric
  2. Devise a white-box testing scheme to test using either execution path or conditional testing.
  3. Based on your testing, correct any errors and provide exceptions to handle run-time errors.
  4. Use the GNU UNIX profiler, gprof, to profile the program and find out which methods most of the CPU time is spent when the Tester class is active.
  5. Based on your profile results, optimise the Rational class (no other classes need to be optimised). Re-run your profile and calculate the percentage speed improvement.

Hints:

  1. Refer to the appropriate lecture notes and book references for further information on metrics, testing, etc.
  2. Once your optimisation is complete, look at compiler options for optimisation. Switch these on and re-test your code. How much speed improvement is possible now?


This material is part of the CSE2305 – Object-Oriented Software Engineering course.
Copyright © Jon McCormack, 2005.  All rights reserved.

Last modified: August 11, 2005