Next / Previous / Contents / TCC Help System / NM Tech homepage

6. Defect statistics

This program was written with Cleanroom intended functions. There was a gap of about three months at a point just before the writing of the processFile() function.

No self-verification or peer verification was done. Defects are counted from the first compilation. Defects are broken down into three categories: see Section 6.1, “Syntax errors”; Section 6.2, “Strong typing errors”; and Section 6.3, “Logic errors”.

6.1. Syntax errors

Syntax errors caught by Python while scanning modules.

  1. In main(), omitted the colon at the end of this line:

        for  archNo in sys.argv[1:]:
    

6.2. Strong typing errors

These are errors that would have been caught at compile time in a more strongly typed language such as Java.

  1. In processFile(), this line:

        result.save ( thumbPath )
    

    did not work, because result is an Imagex object. The desired method is on that object's attribute, result.image:

        result.image.save ( thumbPath )
    

  2. In Imagex.writeNode(), the original code to build the dictionary of attributes for the RNC_IMAGE_N node looked like this:

            attrs  =  { RNC_CAT_NO_A: self.baseName,
                        RNC_WIDE_A:   self.wide,
                        RNC_HIGH_A:   self.high }
    

    However, the DOM expects attribute values to be strings, and self.wide and self.high are floats. Some formatting fixes things right up:

            attrs  =  { RNC_CAT_NO_A: self.baseName,
                        RNC_WIDE_A:   "%.1f" % self.wide,
                        RNC_HIGH_A:   "%.1f" % self.high }
    

    The code above is no longer in the script; the width and height attributes have since been changed to integers.

  3. When writing the archindex.py module, neglected to write the ArchiveIndex.addArchImage() method.

6.3. Logic errors

Ordinary logic errors.

  1. Function processFile() declared a precondition that pathName cannot be the empty string. This precondition was added during design when I realized that the expression baseName[0] would fail with the empty string. I didn't think this was problem, because os.listdir() wouldn't produce an empty file name.

    However, what is tested is the base name, which is the path name without its directory and extension. Unfortunately, a defect emerged in testing. The file name in question was the “hidden file” bird-001/.xvpics. Using os.path.split() on this string yields the tuple ('bird-001/', '.xvpics'), and using os.path.splitext() on that produces ('', '.xvpics'), and the expression baseName[0] fails with an IndexError.

    The fix is to quietly return None whenever the baseName is empty, because hidden files cannot be bird images.

  2. In writeIndex(), neglected to prepend INDEX_DIR to the name of the output file.