TDD Is Great, Just Not for Experimental Programming

Jul 11, 2019 | Test Automation Insights

TDD and experimental programming

Test-driven development, or TDD, can be wonderful for elevating the quality of production software. Plenty of important software in the world, though, falls outside that category. What does TDD offer experimental programming? Not so much. Here’s why.

Spreadsheets rule

TDD is a software programming practice that emphasizes a short development cycle for incremental construction of high-quality, maintainable applications and libraries. TDD yields defect reduction, requirements traceability, code quality, comprehensive regression tests, and other benefits — in some cases.

However, there are times not to use TDD, or to otherwise restrict its application. Considerable (if not entirely conclusive) evidence posits that inspection is even better than TDD in several regards.

Nearly all the discussion around that position is focused on commercial-like programming, and often it emphasizes what I call algorithmic programming. This is almost certainly a minority of all programming. “Spreadsheets are programs and Excel is the most popular software development environment in the world!” Hjalmar Gislason rightly proclaims.

Even in the world of more conventional programs, the emphasis is increasingly on integration rather than “hand-coded” algorithms.

Manage Your Source Code Securely

Hosted and on-prem solutions for Git, SVN and Perforce

Consider experimental programming

One theme that unifies many of these outliers of programming is that they are experimental or exploratory: Rather than a program that will give the right answer when run millions of times, the point is to program just enough to decide on an action outside the programming world.

Consider these examples:

  • A family tosses together a crude spreadsheet calculation to determine whether refinancing a home mortgage might be beneficial.
  • A full-time commercial programmer who practices TDD ties together several licensed APIs to get a feel for the feasibility of outsourcing a thousand requests a second of new functionality to external services.
  • A scientist writes a couple of hundred lines of Java or R or Python to determine whether certain observations are worth exploring as researchable signal or seem instead to be just random noise.
  • A security investigator automates queries against log files in pursuit of likely malicious invaders.
  • A DevOps specialist quickly scripts enough bespoke measurements to diagnose a thorny problem with testing in production.

Replicability, correctness, and other traditional programming metrics are good to have in all these cases. They’re not top priorities, though. Understanding that informs follow-up actions is a higher goal, for instance.

Good TDD might be an advantage in these situations, but it’s not a requirement. Flexibility — the ability to explore possibilities that weren’t even considered when the experiment began — is more essential. Rapid results are also more important.

One complement to TDD in experimental programming is coverage tooling. While most of the examples above are so lightweight that they don’t typically consider coverage, modern coverage tools help ensure that even experimental results are worth trusting.

Context is everything

At its best, TDD is rewarding and even life-altering. However, TDD poorly fits many other common programming situations.

It’s important to be sensitive to context. If your programming emphasizes integration of external dependencies, one-time-only results, answers that you won’t be able to recognize ahead of time, or techniques that blur the distinction between code and data, then you need to plan to use techniques other than TDD to keep your quality high.

All-in-one Test Automation

Cross-Technology | Cross-Device | Cross-Platform

Related Posts:

3 Essential Aspects of a Test Automation Tool

3 Essential Aspects of a Test Automation Tool

  Transitioning into test automation is a wise move for any organization, making it key to choose the right test automation tool for the job. Here, we'll cover how to compare and evaluate a test automation tool like Ranorex. A software test automation tool can...

The Future of Mobile Apps with Ranorex and React Native

The Future of Mobile Apps with Ranorex and React Native

It’s hard to overstate the impact of mobile apps on our daily lives. Smartphones are used for everything from tracking workouts to scheduling important meetings. React Native is a true game-changer in this landscape. Previously, developers had to build apps capable of...

Alpha Testing vs Beta Testing: A Comparative Analysis

Alpha Testing vs Beta Testing: A Comparative Analysis

In software development and engineering, testing plays a pivotal role in ensuring the final product is up to standard. The two most prominent testing stages are alpha and beta testing. To understand these crucial stages, it's necessary to learn about the significance...