You Had Me at TDD (Test Driven Development)


Get On Board!

As I may have mentioned, I'm an old programmer. When I went to college I learned a bit about testing my own software but it wasn't emphasized. At least not in the classes I took in the early 1980's. Somewhere along the line I started hearing about Test Driven Design but I'll admit, I don't remember when or where.

"Uncle" Bob Martin at Software Craftsmanship
In my latest spurt of actually studying software development, one of the sources I've been watching quite a bit on YouTube is "Uncle" Bob Martin. For younger software developers, his name may be more familiar than it is/was to me. Here's an example video: https://www.youtube.com/watch?v=qkblc5WRn-U.

There are a good number of Uncle Bob videos where he discusses TDD; he's one of those (or is the one) that developed the idea of TDD.

Basically, TDD from Bob's perspective means you write a test and run it. It will fail, naturally. Then you write the code that should make the test pass. Run the test. If it passes, then you move on to the next bit of functionality. By the time you've developed the entire module or application, you will know if it works based on whether the tests pass.

I have tried to adopt this philosophy as much as possible while working on my "training" projects.

The Real World (I live in)


This morning I needed to add a simple function to a "Classic" ASP web application. I needed to detect a portion of a host server name. We had some old code that detects for development or local host servers, and needed to add something similar for our test environment.

I decided to use the VBScript InStr function to test whether the host name contains the characters "test". Our test servers can be "test.xxx.xxx", "wwwtest.xxx.xxx", or other variations. And who knows when they might change. But, they'll always have "test" in the host name. So searching for that text seems reasonable.

The first reference I found on line for the syntax didn't explain whether the resulting value would be greater than zero if it found the value in the string being searched. I could infer that the value would be greater than zero because at least one of the results is zero if it doesn't find the search value. But I wish I could test it just to try the boundary tests, etc.

In Classic ASP the only real way that I know how to do a test is to hard code the test in an ASP file that I can execute through a call to IIS and to print out the results. I created the test, ran it, then deleted the code from the host ASP page.

This process makes me appreciate how much  more sophisticated the newer Visual Studio IDE is when it comes to supporting TDD. I believe there are other IDEs that are comparable, but I only use Visual Studio and the built in testing functionality in version 2017. I also appreciate that I'm wanting to take the TDD approach. For that I thank Uncle Bob!

P.S.

Misko Hevery
Yesterday I watched a couple of videos from the Google Tech Talks and enjoyed these two by Misko Hevery that are also related to TDD at Google:

https://www.youtube.com/watch?v=XcT4yYu_TTs&t=3120s

https://www.youtube.com/watch?v=acjvKJiOvXw


Comments

Popular posts from this blog

A better mouse trap - issues with a Logitech Wireless Marathon Mouse M705

Implementing IDisposable Properly

Driver Training - cleaning up unused USB drivers