Profile picture
GeePaw Hill @GeePawHill
, 42 tweets, 7 min read Read on Twitter
okay, twice now i've intro'd this question about the value of m-proof, the rather trivial proof microtests give: what the geek said is what the computer heard is what the geek wanted.geepawhill.org/the-gold-of-mi… and geepawhill.org/the-gold-of-mi…
time to just deal with it, eh?
remember that all of the value that comes from microtests comes before we're done with the program. as we'll see, some of it comes from the fact that the artifacts -- the microtests -- exist at all, and some of it comes from the fact that making them changes our "way".
the microtests have lots of little impacts. in no particular order then, these are the ones i think i see.
before i create them i have to make them doable by me. doing so is not free, and it provides a bunch of constraints that limit my choices. each of those constraints has an impact.
impact: microtests are small and fast and precise, so what they can test must be correspondingly small and fast and precise. in order to even start writing the test, i have to shape the thing being tested so that it's testable in this way. some cases will help make this clear.
i don't hit databases in microtests unless i am specifically testing a specific query at the level of SQL. databases aren't small or fast (or easily controllable, we'll come to that.)
that means that if a piece of logic is interesting and depends on a query's results, i have to shape the invocation so that i can call the logic without calling the query.
that same pattern is ubiquitous in using microtests, especially in the bog-standard IT world, w/its database at the bottom and it's html transport at the top. that is, i also only write test-through-ui microtests when that ui-code is invocable w/o a backend.
impact: microtests must absolutely control the input values and access the output values. that means, to write them, again, i must carefully isolate inputs & outputs rather than binding it all together.
if my outputs are actually stochatic, for instance, based on a PRNG, i have to *own* that PRNG's behavior to microtest them. there is no other way around it. which means i have to be able to *pass* the PRNG i want, not just instantiate one inline or use a global call.
if a microtest makes a call to a framework or library that i can't "just call", i have to isolate the code i want to test from that call.
so the gist of these impacts is just this: they change the shape of the code i am about to write. (this is the steering premise from my underplayed premises stuff, here, geepawhill.org/five-underplay… ).
there are other similar impacts. what they add up to is a code base, a *shipping* code base, that has a different shape than if i did not write the microtests.
*because* of m-proof, my TDD'd code will have smaller classes, smaller methods, more immutability, far higher collaboration. it will have fewer inline "new's", more very-small interfaces, far more delegation. it will tend towards pluggability.
the impact of all of these is *huge*. many of us believe that the combined impact is a remarkable drive towards what we now regard and teach as "generic software design principles", stuff like SOLID, or the DRY concept.
i think of it this way: i can remember all the principles, study design, master my patterns, and so on, or i can just make sure all the branches and calculations in my code are microtested.

either way, i get the effect i wanted.
the microtests, and their dumb little m-proof's aren't done adding value yet. far from it.
everything we have so far mentioned would be important and valuable even if all code were write-right, write-once, and write-solo.
write-right meaning "we never make a mistake in our typing". write-once meaning "we never change code we've already shipped". write-solo meaning "we never work with other people's code".
but in fact, all three of those are completely bogus propositions in the world of a professional software geek. (sadly, they're not always considered bogus in the *mind* of a professional software geek. that's why i'm out here doing this.)
and here's where the microtests and the dinky m-proofs really shine. when we make mistakes, when we change things we've shipped, when we work with other people, the m-proofs are invaluable. we've gone from useless dust to interesting iron already, now we approach gold.
impact: the microtests force one person to say the same thing in two different ways, once in the code, and once in the microtest. the number of -- technical term here -- *dumb-assed* defects this catches is -- technical term here -- *gigundous*.
it's nearly impossible to grasp this without experiencing it IRL. we might notice ourselves making dumb-assed mistakes all day long, but it is incredibly hard for the human mind to really see how many of them we make or how much time making them wastes.

microtests *kill* those.
impact: microtests in shipping code that i'm about to change mean that i can not possibly break what is shipping without discovering it before i push.
this is easier to grasp w/o experience, but also easy to underrate value-wise. think about your defect lists. how many of those shipping defects were in code that *was* working just fine last month? how many were the result of fixes? or fix-fixes, or fix-fix-fixes?
microtests don't kill this kind of thing as well as they kill dumbassedness, but they do dramatically improve your defect rate.
(aside in a muse that's already long: my first big success converting a victim to TDD came from a fix he and i put in to microtested code. it made our new test green and broke 40-odd old tests. we went for a smoke. gary said to me: "huh. i guess this TDD shit works, doesn't it?")
impact: microtests provide a kind of executable spec -- a document you can run -- for any code you either have never seen or do not remember. the perfect answer for "how do i use this thing?" is "watch how its tests use it."
two reasons this matter.

first, because the modern geek is a collaborator something like 95% of the time. the size of modern applications requires this. working with other people's code is critical to our ability to ship.

and there's another reason related to size.
second, because modern applications are *unbelievably* large and intricate. a typical boring database-to-web app uses five formal languages and has dozens of modules, some of which have hundreds or thousands of APIs.

it is flat impossible for one person to hold in their heads.
this means that i am constantly in the situation where i have to work with stuff -- even stuff i *wrote* -- that i do not know. you can laugh in my case cuz i'm elderly, and that can include code i wrote yesterday morning. but it's true for all of us.
this "executable spec" impact is a tremendous force-multiplier. it allows me to pick up a new thing and use it far more quickly than a written spec, or, more commonly, random guessing based on API name.
and if i have a question anyway about how something works? if it's microtested it's microtestable: if the test i'm curious about doesn't exist, i can roll it myself and find out the answer.
one more impact, then i'mo cut you loose for the day.

impact: microtests run in a separate app that is not the shipping app. anything i do with or through them is almost certain to be faster, cleaner, more stable, more accessible, and more precise.
i watch geeks in non-TDD shops do a thing all day long: compile. launch. wait. wait. wait. type 3 characters, click twice. wait. wait. wait. remember to change the config. wait. wait. wait.

once you notice this, you realize the amount of "dead time" is just staggering.
microtesting doesn't eliminate running of the shipping app, that'd be a ludicrous statement. but an overwhelming majority of the time, the small changes we are makng change aspects of that app that constitute <1/10000th of what it can do.
and in any case, if my little change doesn't even do what *I* wanted it to do, what's the point of firing up the app to discover that it doesn't have the downstream effect i wanted it to have?
i just have to wrap this monster pretty quick. one thought and one foreshadowing, and we're on our way...
thought: like so much of this movement's styles, microtests and TDD aren't meant to make hard problems easy. they're meant to make *easy* problems easy. that sounds like small change, but it's not, cuz the old-school way makes all problems, easy or hard, cost the same amount.
foreshadowing: i still haven't connected all this to the triad fully. if you buy my crazy theories, the movement is founded on expanding the focus past "the made", to "the making" and the "the maker".

we'll get there, but i may stop for a day or two and do something else.
thank you for reading this great baggy muse.

have a strange saturday night!
Missing some Tweet in this thread?
You can try to force a refresh.

Like this thread? Get email updates or save it to PDF!

Subscribe to GeePaw Hill
Profile picture

Get real-time email alerts when new unrolls are available from this author!

This content may be removed anytime!

Twitter may remove this content at anytime, convert it as a PDF, save and print for later use!

Try unrolling a thread yourself!

how to unroll video

1) Follow Thread Reader App on Twitter so you can easily mention us!

2) Go to a Twitter thread (series of Tweets by the same owner) and mention us with a keyword "unroll" @threadreaderapp unroll

You can practice here first or read more on our help page!

Did Thread Reader help you today?

Support us! We are indie developers!


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

Become a Premium Member and get exclusive features!

Premium member ($30.00/year)

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

Donate via Paypal Become our Patreon

Thank you for your support!