so, for those following along, the other day i had to decide whether to roll my own parser for boolean expressions involving tags, like "(stinky & doofus) | (ugly)". very standard stuff.
in the end, i rolled my own, and i have to tell you, i just had a really wonderful time.
a parser for strings is an absolutely awesome place to do TDD. they're just *strings*. no clever fakes, no extract & override, nothing. just strings.
i hadn't done a recursive descent parser in years, so first i ripped some internet code and mucked around in it until i grasped it all again.
then i tossed that, and TDD'd based on what i'd learned. rdp's are nice, cuz you basically start at the bottom and add wrapping function at each step, but the call you make to fire up the parsing is the same every time, the wrapping is all internal.
anyway, now i have a lovely parser. it's smart about errors, and hooked into a live editing box, so the user can type the expression. as they type, the text is red if i can't parse it, green if i can, and i update the applied filter every time it's green.
there were plenty of screwups along the way, and the TDD was just sitting there doing it's TDD magic perfectly. i swear to god if i'd had to find all the little regressions i created as i was adding new function, it would have taken at least an order of magnitude more time.
i've found three bugs since it went live, and i true-blue TDD'd them: added a new red test before i fixed the problem, got it red, then got it green. it was really a very pure process.
one of the reasons i decided to take up the mantle of teaching TDD: situations as clean & pure & delicious as these are actually quite rare in the workaday world of geekery.
and it seemed to me a lot of folks out there were suggesting that TDD is red-green-refactor all day, an endless spiral of rainbow-farting unicorns and never ever ever a judgment call or a frustration or an impure thought or act.
a working geek using TDD knows that we don't normally do greenfield work in toy codebases with only leaf dependencies that we wrote ourselves. hardly ever do we get the chance to just let the tests flow like wine.
so then why do i persist in applying TDD in situations in which it's not pure and easy? why do i teach TDD if it's not normally universally straightforward and learnable in cute little soundbites?
well here's the thing. when i *do* get those simple pure situations, i code like a god among geeks. i am faster, stronger, smarter, and what i ship stays shipped. it's not just a little better, it's fantastically better.
and somewhere in my second year of trying TDD everywhere, i began to see situations that were *almost* simple and pure. one tiny change i could make, and they would be pure TDD situations.
and i kept going, and that trend kept going. ever larger impure situations i became able to see how to change into pure ones. and it was very often very worth the effort to make those changes.
two duffers are at the billiard parlor watching the local hero get his ass whipped by some out of town star. the one guy says, "man, that stranger is *good*." the other one says, "oh, idunno. he never takes a hard shot."
this is the heart of the steering premise. we don't force TDD to take hard shots. in fact, that forcing is what makes TDD duffers decide they hate it, that we're all mouth-foaming religious fanatics, and that TDD can never work in *real* life.
baby TDD is red green refactor. grownup TDD is taking the shots that look hard at first blush, then rearranging things until they're not hard, then baby-TDDing them.
and i teach this because it has made me a vastly stronger geek. and i can easily imagine duffers looking on: "oh, idunno, he never takes a hard shot."
the steering premise says "tests & testability are first-class participants in design". it means, in the simplest telling, "don't take hard shots. when you can't test this design in an easy shot, change it until you can."

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with GeePaw Hill

GeePaw Hill Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @GeePawHill

Feb 19
Awwwww shit, swear to God on my Momma's headstone it came up on the play list.

Roy Byrd & His Blues Jumpers, "Byrd's Blues".

1949.

19*Forty* *Nine*.
It was Byrd -- Professor Longhair -- who should have been the base of rock'n'roll. Imagine, I mean, imagine, if this were the root.
Read 4 tweets
Feb 19
Kate Bush, "Houdini".

I think, sometimes, I have not properly honored this artist, Kate Bush.
This song is the song of Bess Houdini, the Bess of Erich Weiss. Wife to the highest paid entertainer in the world.
Read 12 tweets
Feb 16
In re: exceptions in Java. I used SocketServer.accept() the other day. Now, for the unwashed, accept() is a blocking function in an async environment. It's for listening to see if someone connects to the listening port.
And what if -- I did -- you want to listen for this, but in an exitable way, so that, say, if no one connects for a second, you regain control and can do something else, for instance.
Here's how you do that:

try {
serversocket.setTimeOut(xxx)
serversocket.accept()
}
catch(SocketTimeoutException ignore) { }
Read 8 tweets
Feb 13
Glen Campbell, "Wichita Lineman"

Campbell, who lived at the pivotal moment when we turned from great singers to great singer-songwriters, is, even now, much maligned.

But his tenor was good, and his taste was good.
It's a Jimmy Webb song.
Read 4 tweets
Feb 12
Aight, light. I'm going light. We're doing light.
Here's Harry Nilsson, "Coconut".
Taj Mahal, "Fishin' Blues".

Read 5 tweets
Feb 12
I have been mulling, stalling, hedging, thinking, strategizing, so on and so forth, on a new project I've had in mind, for at least six months.

I think I'm about to pull the trigger on it.
And I'm not even gonna tell you what it is.

Because all the mulling, stalling, hedging, etc etc et fucking cetera had almost nothing to do with the geekery.
I make content for a living, or, more correctly, I make content for a non-living. I have project after project, three of them alive currently, to serve as the base and motive for my content.
Read 10 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(