the judgment premise is one of five underplayed tdd premises.
the judgment premise is simple to word and vast in its extent. it says, “tdd relies absolutely on individual humans using their human judgment.”
you might ask yourself, “what *doesn’t* rely on human judgment?” but there are lots and lots of activities that are entirely mechanical, judgment-less, and geekery is full of them. we *work* with judgment-less systems every day. we call them “computers”.there’s merit to “algorithmizing”, that is, making computable sequences that can replace ones that require human intervention, *much* merit. but sometimes our zeal for this activity gets the better of us.
the modern synthesis in coding, what i normally call TDD, but meaning TDD in the broadest sense, has at its core four activities: writing tests, making them pass, change-optimizing the code, and pushing the result to head. (i shorthand them to red, green, gold, push, and i trust you’ll know what i mean going forward.) in its simplest expression, we can see these as a simple cyclical sequence: red, then green, then gold, then push, then start over. we can elaborate on this — i’ve done so and many others have, too — to create a fancy flow-chart thing from it.
the judgment premise says that every one of the bubbles on this psuedo-algorithm is fraught with the requirement that humans use non-computable means to control it — to refine it, to transition around it, to actually *do* TDD.
the originators knew this, of course, and the serious practitioners know it, too. that’s why i call this a premise: it is baked-in all the way through. it’s an *underplayed* premise, in my view. we don’t make a big enough deal about it. that’s because when you’re inside TDD, your confidence in the premises is complete. they’re the air we breathe, and like that air, largely invisible but essential to our success.
the judgment premise, like the rest, is an effort to make this air visible to us. let’s look at those four core activities, with an eye towards spotting the non-computable human judgments they involve.
getting to red involves numerous judgments. first, of course, there’s the simple question of whether or not the code i’m about to put in calls for a test at all.i don’t test a function called ‘getX()’ that returns a field called ‘x’s value. i don’t know of anyone who does. my judgment is that such a test wouldn’t pay for itself. note: that’s not to say i never fuck up the implementation of ‘getX()’. it’s to say that when i do that, occasionally, i discover it so easily, usually the very first run, that writing a test for it would be a waste of time. (the money premise rears its mammonist head.)
the “no test for getX()” judgment isn’t a no-brainer, cuz no-brainers aren’t judgments, but it’s a tiny-brainer. as we proceed at getting to red, tho, some of these similar “no test for” decisions become quite a bit more brainy.and it isn’t just whether or not to test it’s very often *what* to test. recently, i was laying out some UI in javafx, whose layout strategy is fuzzy AND buggy. i did most of my basic testing using a skeletal disconnected “ui-only” app with a GAK (geek at keyboard) approach.
i came to understand that if i wanted perfection, i needed to do the layout math “manually”. that is, give me the width & height of client area, and let me compute and assert the layout from that. and *that* computation, i tested with a bunch of automated cases. there are still no tests for the actual rendering: my judgment has been validated visually.
a third judgment in getting to red: is this the right time to write that test? an extremely common move in the TDD game: sketch out a test and defer it. sometimes i write the test and mark it ignored, sometimes i jot a note, sometimes i count on my leaky head to remember.
there are others i’m not thinking of just now, i feel sure. but let’s move on to green. once i have a failed test i like, i get it to pass. here, the use of judgment seems so gigantic and obvious it hardly needs enumeration.
which methods change? which objects get made? how do they interact? do i need more data, less? do i replace/extend this existing method, or do i need a whole new thing? all of these are judgment calls. they’re based on heuristics, on intuition, on sketches, on conversations, on habits and even mood. they are not computable.
when that test and all the other tests are green, we then hone in on the design of the code. refactoring — getting to gold — is the business of optimizing our code for changeability. as with getting to green, i feel sure i don’t need to point out the level of delicate decision-making that goes on during the gold step. the fact is, change-optimizing code engages my judgment more fully than any other work i do.
that maximized-judgment thing, btw, is why your old master geek coaches seem to enjoy refactoring more than any other part of the work. it feels so *good* to use all of oneself in a single activity, logic, experience, intuition, anticipation. if companies were bright enough to pay us just to refactor code, i and many of my geek-coaching confreres would do nothing but that. it feels so much like the maximum expression of our long lives in geekery.
pushing code, the fourth big blob on our psuedo-flowchart, is sometimes elided from the TDD skeleton, but it’s tremendously important. much of the benefit of TDD in teams is captured because of continuous integration.
sometimes after green i push, sometimes i don’t. i decide on the spot, a judgment. further, sometimes i’m midstream in getting to red or green or gold, and i “anti-push”. i revert. that’s a decision i usually make through some abstruse mixture of elapsed time & anxiety. (aside: we need to teach more folks about the huge value of restarting. i revert work-in-progress all the time, instead of always and only laboring on. i learned this only because i was practicing CI in very small cycles.)
the judgment premise is about the humanness of the software development enterprise, even that part of it, TDD, that is closest to the metal.
i’m not hating here on the many psuedo-algorithms we make. as i say, i’ve done it myself. i understand the impulse, and they can be very helpful (briefly) to folks at the beginning of the climb. but psuedo-flowcharts are training wheels. riding a bike with training wheels, however important as a short phase, isn’t being a cyclist. if you’re going to engage with the modern coding synthesis, with TDD, refactoring, CI, CD, and so on, you’re going to be constantly using the non-mechanical parts of you.
the judgment premise: in TDD we are absolutely, continuously, ineluctably, and *happily* entirely reliant on individual huamsn using their best individual judgment.