The right way and the practical way

Brent Simmons, Reason Number 33,483 to Hate Programming:

Or I could have the superclass expose the appIsTerminating property in its header file, so that the subclass could see it. This also sucks, because a controller class has no business exposing its own copy of global application state.

In the end, though, that’s what I did. (Along with a comment that the property was there for subclasses.)

It reminds me that there are two competing values:

  1. Do everything the right way every time.

  2. Make responsible and professional decisions about time and expenses and benefits and drawbacks.

My nature is to take path #1. It is so hard for me to take path #2. I have the utmost respect who can work on sprawling, modern software and stay on path #2. But path #1, always pulling me in and sending me down rabbit holes.

Sometimes I wonder which of these paths got me to where I am in my career. Others, I wonder if I think I’m a everything-the-right-way person but really I’m a responsible-and-professional-tradeoffs person.

A brain’s a weird place to live.

Contrast NYC and SF

Dallas and Austin are the cities I’ve spent my life in. I’ve spent maybe three weeks of my life, total, in San Francisco and New York City. They’re similar in that SF and NYC are both a Whole Other Thing in comparison to my Texan expectations. Indeed, they’re global cities operating at an entirely different order of magnitude.

It’s long puzzled me why I find NYC less intimidating and strange than SF. I’m starting to think its the attitudes. Walking through either town, I frequently suspect that I’m Doing It Wrong, from where to eat to where to sleep to how to use the subway.

In NYC, I suspect the natives are looking on as I struggle to hail a cab or catch a train, but they are silent in their snickering about me doing it wrong.

SF feels much more in your face, eager to tell you “You have done it wrong and you should feel bad”, from the subway systems to the tech bubble.

San Francisco very much remains a frontier town. You move there to make your fortune, to burn bright and “compress your career into several years”. It’s at the same time fractured by law (the city has three different transit systems, all using different tokens last time I visited) and lawless (Uber and Airbnb in particular are about landgrabs before the law can catch up with technology). It’s at once a global city and embarrassingly self-centered.

In summary, I guess I just like Texas a lot better. Even after our awful lawmakers.

Framework and Library people

By unscientific survey, I think many developers would prefer to work in a “framework world” where many decisions of principle and organization are passed down by a vendor or architecture team. Think Rails/Django/Laravel for backends, Ember/Elm for frontends, Unity for games. These are the Framework people.

Fewer developers would prefer to create their own world, building up tools and libraries to suit. They select a few first principles and build their own world. They’re the bebop jazz musician, eschewing big band gigs and music people can dance to to create their own intellectual world. These are the Library people.

I’m a Framework person. The allure of Library people sometimes tempts me after I look at a beautifully-restored car or a well-structured song. But constructing a library world is thankless and not particularly high leverage, unless you succeed in creating something for framework people. Weird, eh?

Execution and idea in Frontierland

It’s commonly held, and pretty much true, that ideas are shallow and execution is depth. That is, the former is nothing without lots and lots of the latter.

Let’s set aside how “execution over ideas” is used as a bludgeon for a moment. I think there’s possibly a case where “execution AND idea” is a viable recipe for success.

If you’re in a Wild West, converting the minimal version of the idea to an executed offering can be all you need to succeed. Temporarily.

If you’re always moving from emerging market to emerging market, you’re betting not on your ability to execute, but your ability to identify the next market. You’re OK with fast followers building on your idea, iterating on it, and establishing themselves as the market matures. That’s OK, because you’ve already moved on to the next market.

So the risk here isn’t execution, but idea/market selection. When you’re first, it’s slightly OK to ship with a product that will be viewed as laughable once the market is mature. 75% idea, 25% execution.

When you’re second, seventh, or seventeenth, you had better execute on the idea, the business, and the culture you build. It’s 95% execution, 5% idea.

Empathy Required

Nearly fourteen years ago, I graduated college and found my first full-time, non-apprentice-y job writing code. When I wrote code, these were the sorts of things I worried about:

  • Where is the code I should change?
  • Is this the right change?
  • What are the database tables I need to manipulate?
  • Who should I talk to before I put this code in production?

Today, I know a lot more things. I did some things right and a lot of things wrong. Now when I write code, these are the sorts of things I worry about:

  • Am I backing myself into a corner by writing this?
  • Why was the code I’m looking at written this way and what strategy should I use to change it?
  • Will this code I just wrote be easy to understand and modify the next time I see it? When a teammate sees it?
  • Should I try to improve this code’s design or performance more, or ship it?

Half of those concerns are about empathy. They’re only a sampling of all the things I’ve learned I should care about as I write code, but I think the ratio holds up. As I get better and better at programming, as my career proceeds, I need more empathy towards my future self and my teammates.

Further, that empathy needs to extend towards those who are less experienced or haven’t learned the precise things I’ve learned. What works for me, the solutions that are obvious to me, the problems to steer clear of, none of that is in someone else’s head. I can’t give them a book, wait three weeks, and expect them to share my strengths and wisdoms.

That means, when I advise those who listen or steer a team that allows me to steer it, I have to make two camps happy. On one hand, I have to make a decision that is true to what I think is important and prudent. On the other hand, I have to lay out guidelines that lead the listener or teammate towards what I think is important or prudent without micromanagement, strict rules, and other forms of negative reinforcement.

It’s so easy, for me, to just hope that everyone is like me and work under that assumption. But it’s much better, and highly worthwhile, to figure out how to help friends and teammates to level up on their own. It requires a whole lot of empathy, and the discipline to use it instead of impatience. Worth it.

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 Kottke.org, 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.