GeePaw Hill Profile picture
Feb 10 15 tweets 3 min read
Avoiding fakes, I'mo telegraph this, cuz so many have asked, but the truth is February is my personal ebb-tide, and as much as I wish I could lay it out at the primer level, I simply don't have that in me right now.
Start by knowing who's awkward and who's not, and why. Identify which collaborators are awkward. You can read about awkwardness here:

geepawhill.org/2021/02/12/awk…
Now go look at your function that needs a fake of that awkward collaborator. It needs that fake because the awkward call is surrounded by logic you need to test.
Most of those functions, the overwhelming majority of them, will be shaped like this

//... some lines of prolog code
awkward.call(...)
// ... some lines of epilog code
What do I mean, prolog? Well, it's the kind of code that figures out whether we should be calling the awkward, or it's the kind of code that takes some input and cooks it a little to create the arguments for that awkward call.
What do I mean by epilog? It's the kind of code that takes the result of that awkward call and cooks and massages it, or makes decisions based on its return.
That shape: prolog - awkward - epilog, that shape is why you need to have a fake to test that function.
But, one naturally asks, what the hell am I on about, it's not like you don't need the prolog and the epilog. I can't just not prepare before the call or not cook after the call. Bah, humbug, you cry!
The fix is simple. Change that code to read:

function() {
a = prolog()
b = awkward.call(a)
return epilog(b)
}

Or if you're comfy with compaction:

function() {
return epilog(https://t.co/G04Y7dzZo7(prolog()))
}
Bam. Test every case of prolog(). Test every case of epilog(). Test every case of awkward.call().

*Don't* test function().
How often does this scam work? VERY VERY OFTEN. It does not always work. Some loops develop their results incrementally, so my one call to awkward depends on my previous call to awkward. There is no way to test that w/o a fake.
But in nearly every other case, you can gain complete satisfaction without a single fake being in play.
There are a couple of special cases of all this, and some pretty damned slick technique that can handle the cases not covered by this trick. That's for another day.
Listen: You are a beautiful and intelligent creature, and you can do this.

But you gotta want to.
Learn "composed method".
Learn "strategy".
Learn "replace supplier with supplies".

This will still leave you with that tiny number of cases where you gotta roll a fake.

Roll it by hand, don't use an auto-mocker.

It will make you faster and stronger and, yes, happier.

• • •

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 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
Feb 11
Killing time while I wait for my birthday drink(s). I am prowling around a large java code base, looking at code I regard as "good", and partly picking nits and partly re-envisioning it in Kotlin idiom.
It is fun, sometimes, to look at bad code from lousy designers. But I am enjoying looking at reasonably good code from a designer I have a lot of respect for. Feels like it's even more fun.
A f'rinstance nit: don't use inline if's to handle pre-configured optional steps in an algorithm. Use a Strategy constructed at configure-time.
Read 14 tweets
Feb 10
I read in bars, or anyway, I used to read in bars, when bars were a place I could go to. I miss bars terribly, and I miss reading in bars, too.
I like bar culture. And, tho I am of course a junkie, I have spent many an hour in bars, dead sober, reading my book and drinking my Diet Coke.
I have a friend, Sandy, who was the bartender at a place that was once my local. And I went in two or three times a week. I'd be there for very long stretches, six or eight hours, even.
Read 7 tweets
Jan 27
True story: Eighteen or so years ago, I had a gig rolling code at an engineering company. We were writing a windows app using Microsoft Foundation Classes to drive a TTY interface to a box of various radio hardware junk.
I was gigged in by a guy I'd taught a c;ass (in MFC) to, because he liked that I knew my shit, and he loved that I spoke openly about joy, right in the classroom. right in front of God and everybody.
G amd I got along great. We were both heavy smokers and committed drinkers and hardcore software geeks. We spent many an evening after work, just hanging out, talking about geekery, smoking cigarettes, and drinking like fools.
Read 16 tweets
Jan 26
Kate Bush, "Night of the Swallow".

The Dreaming was the first album I heard from Bush. It is stunning. I mean, every take, it is stunning.
Bush is one of the greatest "I may in fact be hopelessly insane" singers of all time, but whackos are a dime-a-dozen, what's astonishing about her work is how she works to give you the *grounding* you need to hear the insanity.
Read 4 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!

:(