Good Habits for Great Coding by Michael Stueben

Good Habits for Great Coding by Michael Stueben

Author:Michael Stueben
Language: eng
Format: epub
Publisher: Apress, Berkeley, CA


This test code is good enough to catch obvious errors, and that is all smoke tests should do. When I finally came to write the binarySearch, almost every logic error was immediately exposed by this test code. Of course, fixing one error would introduce another error, but the smoke test usually caught that error too.

The binarySearch function took me 70 minutes to write (passing the smoke tests) and to refactor. How confident was I about my binarySearch? Not very, because smoke tests are crude. The final step was to create and test 1000 random-sized sorted arrays of random integers. Then every possible number in each array, and some not in each array, were searched for. The following code does this.

def binarySearchTest():

runs = 1000 # The number of random arrays to be tested.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.