Copypasta, you’re the worst pasta

Copypasta. It’s the worst. “I need something like this code here, I’ll just drop it over there where I need it. Maybe change a few things.” Only you can prevent headdesks!

It’s not really possible, in my experience, to make it easier to use code through methods and functions than to just copy what you need and start changing it. No amount of encapsulation or patterns is easier than a pasteboard.

Perhaps, copypasta’s natural predator is a well-informed code review. There are tools, like flay, that can detect some kinds of code duplication.

But for the most part, it’s a battle of dilligence.

(Ed. I found this in my draft folder from four years ago. Copypasta; copypasta never changes.)

Through mocks and back

A problem with double/stub/mock libraries is that they don’t often fail in a total manner. They don’t snap like a pencil when they’re used improperly. Instead, when you use them unwisely, they lay in waiting. At an inopportune time, they leap out.

Change an internal API method name or argument list and your poorly conceived doubles will moan. Rearrange the relationship between classes, and your overly-specific stubs won’t work anymore.

At some point, I felt pretty handy with mocks. Then I wrote a bunch of brittle mocks and decided I needed to go back to square one. I’m through the “just avoid mocks” phase, and now I use them sparingly.

Favor a better API in the code under test, then hand-coded fakes, then stubbed out methods, before finally falling back to a mock. Someone, possibly yourself, will thank you later.

Stevie Wonder, for our times of need

Tim Carmody writing for, Stevie Wonder and the radical politics of love:

Songs in the Key of Life tries to reconcile the reality of the post-Nixon era — the pain that even though the enemy is gone, the work is not done and the world has not been transformed — with an inclusive hope that it one day will be, and that faith, hope, and love are still possible.

It’s what makes the album such a magnificent achievement. But I’m not there. I don’t know when I will be. So for now I’m keeping Songs In the Key of Life on the shelf. An unopened bottle of champagne for a day I may never see. But I’d like to.

On three of Stevie Wonder’s best albums, his political writing, and how he bridges saying something and making a good song.

I cannot wait to listen to Songs in the Key of Life again.

How Disney pulls me in

Dave Rupert, Disneyland and the Character Machine:

In October my family took a trip to Disneyland. I couldn’t help but be infected by the magic of Disneyland that allows you to feel young at heart and compells you to wear mouse ears on your head. Walking mile after mile through the park it’s very clear this magic has been painstakingly created and preserved by paying the utmost attention to detail.

There’s magic in paying attention to detail, it’s the slight of hand that helps seamlessly preserve the illusion. At Disney, not only is the illusion preserved, you’re encouraged to take part through cosplay and interacting with your favorite characters. This makes you not just an observer, but also a participant in the ritual.

The level of detail is amazing, completely intentional, and interconnected. You can’t see Tomorrowland from Fantasyland because that would take you out of the moment. You can ask Ana from Frozen about her favorite chocolate because she loves chocolate in the movie.

More than a theme park, Disneyland and Disney World are movie-like experiences you can walk around in, immersed in the joy and excitement of the setting and story.

Does an unadvertised extension point even exist?

There was an extension point, but I missed it.

I was adding functionality to a class. I needed to add something that seemed a little different, but not too far afield, from what the existing code was doing. So I came up with a good name, wrote a method, and went about my day.

A few weeks later, trying to understand an obscure path through this particular class, I found the extension point I should have been using. On one hand, eureka! On the other hand, why didn’t I notice this in the first place?

Did I not consider the open/closed principle enough? Perhaps my “modification” sense should have tingled, sending me to create a new object to encapsulate the behavior with.

Was the extension point hidden by indirection? Perhaps the change going into an ActiveRecord model through me off; I was doing as you’d normally do in a model. I wasn’t expecting another layer of abstraction.

Were my changes too scattered amongst many files? I had modifications in a half-dozen files, plus their tests. It’s possible I was juggling too many things.

Probably it’s all of these things. Lesson learned: when I get to feeling clever and add a handy extension point to make the next person’s job easier, advertise that extension point and make it clear this is probably where they want to make their change.

Perhaps there’s a benign explanation for Paul Ryan appearing to have cut off his phones. Anecdotally, it does not seem GOP Congresscritters are putting much effort into their voicemails or phone lines. I called my representative, Lamar Smith, yesterday afternoon, incensed that he had suggested we listen to Trump and not the media. Both his DC and Austin voicemails were full. I was able to get through this morning and spoke with a staffer who was dismissive but polite.

This practice of neglecting voicemails and only dismissively answering phones during office hours is appalling. The job of our Congress is to represent us. They cannot do that job if they aren’t taking every voicemail, phone, and email into account. Very rarely do I get the feeling Congress wants to even appear they are doing their job.

If I didn’t answer my work email, I’d lose my job. But Congresspeople don’t lose their jobs except for during an election or certain kinds of partisan maneuverings.

Fire Congress anyway. I’ve started with the phones and a whole lot of pent-up frustration. Maybe the infernal hell of fax machines is next?

The TTY demystified. Learn you an arcane computing history, terminals, shells, UNIX, and even more arcanery! Terminal emulators are about the most reliable, versatile tools in my not-so-modern computing toolkit. It’s nice to know a little more about how they work, besides “lots of magic ending in -TY”, e.g. teletypes, pseudo-terminals, session groups, etc.

Our laws are here, they just aren’t equally practiced yet

That thing where institutions like the FBI are prohibited by law from meddling with presidential elections, and then the FBI meddled multiple times. We’re just going to let that slide? Seems like it!

The point is not there was one big injustice, which there was. The point is that justice has been distributed unevenly through your history. Outcomes favored by those in power but obtained illegally have long been effectively legal. Those out of power have always felt the full brunt of the law, and even worse.

The inequality and imperfection by which our law has always been practiced. That’s the lesson.

Journalism for people, not power

Journalism is trying very hard to do better, but still failing America. Media is covering politics and not “We, the people”.

Take the coverage of the Republican attempt to neuter congressional oversight and subsequent retreat amidst tremendous scrutiny. Coverage typically read “Donald Trump tweeted about this and by the way a ton of people called their congressperson.” The coverage is focused on what a person in power says. A fascination with celebrity and power.

It’s not focused on the readers, or the people who bear the actions of politicians. Certainly not the disadvantaged who can’t even keep up with politics because they have neither a) the money for a newspaper subscription or b) the time to follow it all between multiple jobs and possibly a family.

It’s focused on what politicians are saying the people want. It’s easy to get a politician to talk about this. That’s part of their job now, skating the public discourse towards the laws they want to pass.

It’s focused on what think tanks want to talk about. Those talking heads on TV and think pieces on the opinion pages? It’s easy to get those people to talk because they’re paid to do those things by giant lobbies and interest groups. They’re paid to get in front of people and tell them what laws they should want.

Journalism should counteract these extensions of the corporate state. When a politician, funded by a lobby, says “the people want affordable health care”, a print or television journalist should say “and here’s what three people not involved in politics actually said”. Maybe they’ll agree with their politicians, maybe they won’t!

When a politician says “we should lower taxes on the top tax bracket”, media should follow up with that that means. Who exactly gets that tax break? Will actually benefit other people? What do people who don’t benefit from that tax break gain or lose because of it.

The next news cycle will come up, the politicians will say one thing. The truth and tradeoffs will reflect another truth. The journalists will go out there and talk about the tradeoffs and what people think now. And then maybe we’ll get a more educated society.

Likely this means the sports and entertainment pages have to subsidize the political coverage. Or we need to start recognizing pieces stuffed with quotes from think tanks and politicians as “advertorial” and not news.

Regardless, political journalism as zero-sum entertainment has to go.