Sample Video Frame

Created by Zed A. Shaw Updated 2024-02-17 04:54:36
 

Exercise 27: tr

This exercise is continuing the study of doing TDD (aka Test First) style development. It's important to know how to do this kind of programming since it is used in many places, but as mentioned before it does have its limitations. You'll be doing one more exercise using TDD while implementing the tr command. Be very sure that you are being strict about writing your test first, then the code, then audit both.

In the previous exercise I told you to build your test case and your code incrementally. This is usually the least error prone method of development, but it doesn't help you get better at analyzing your own code. In this exercise you're going to do things slightly differently as I'll have you write a whole test case, audit it, then write the whole code, audit it, and confirm your audit by running the tests.

That means in this exercise your process is this:

  • TDD a test case, attempting to write most of it.

  • Audit the test case and confirm it is written correctly.

  • Run the tests to ensure they fail, but look for any syntax errors. You should not have syntax errors at this point.

  • Write the code for the test case, but do not run the test.

  • Audit your code, and try to see how many defects you find before you run your test.

You'll be using this procedure in the next exercise to track metrics on your auditing skills, your testing skills, and to be more controlled in how you write code.

Previous Lesson Next Lesson

Register for Learn More Python the Hard Way

Register today for the course and get the all currently available videos and lessons, plus all future modules for no extra charge.