How I build software quickly

by
, updated (originally posted )

Software is built under time and quality constraints. We want to write good code and have it done quickly.

If you go too fast, your work is buggy and hard to maintain. If you go too slowly, nothing gets shipped. I have not mastered this tension, but I’ll share a few lessons I’ve learned.

This post focuses on being a developer on a small team, maintaining software over multiple years. It doesn’t focus on creating quick prototypes. And this is only based on my own experience!

“How good should this be?”

Early in my career, I wanted all my code to be perfect: every function well-tested, every identifier elegantly named, every abstraction easily understood. And absolutely no bugs!

But I learned a lesson that now seems obvious in hindsight: there isn’t one “right way” to build software.

For example, if you’re making a game for a 24-hour game jam, you probably don’t want to prioritize clean code. That would be a waste of time! Who really cares if your code is elegant and bug-free?

On the other hand, if you’re building a pacemaker device, a mistake could really hurt someone. Your work should be much better! I wouldn’t want to risk my life with someone’s spaghetti code!

Most of my work has been somewhere in the middle. Some employers have aggressive deadlines where some bugs are acceptable, while other projects demand a higher quality bar with more relaxed schedules. Sussing this out has helped me determine where to invest my time. What is my team’s idea of “good enough”? What bugs are acceptable, if any? Where can I do a less-than-perfect job if it means getting things done sooner?

In general, my personal rule of thumb is to aim for an 8 out of 10 score, delivered on time. The code is good and does its job. It has minor issues but nothing major. And it’s done on time! (To be clear, I aim for this. I don’t always hit it!) But again, it depends on the project—sometimes I want a perfect score even if it’s delayed, and other times I write buggy code that’s finished hastily.

Rough drafts

Software, like writing, can benefit from a rough draft. This is sometimes called a “spike” or a “walking skeleton”.

I like implementing a rough draft as quickly as I can. Later, I shape it into the final solution.

My rough draft code is embarrassing. Here are some qualities of my typical spikes:

This sounds pretty bad, but it has one important quality: it vaguely resembles a good solution.

As you might imagine, I fix these mistakes before the final patch! (Some teams might pressure me to ship this messy code, which I try to resist. I don’t want the rough draft to be treated like a final draft!)

This “rough draft” approach has a few advantages:

Here are some concrete things I do when building rough drafts:

See also: “Throw away your first draft of your code” and “Best Simple System for Now”. “YAGNI” is also somewhat related to this topic.

Try to change the requirements

Generally, doing less is faster and easier! Depending on the task, you may be able to soften the requirements.

Some example questions to ask:

More generally, I sometimes try to nudge the culture of the organization towards a slower pace. This is a big topic, and I’m no expert on organizational change! But I’ve found that making big demands rarely works; I’ve had better luck with small, gradual suggestions that slowly shift discussions. I don’t know much about unionizing, but I wonder if it could help here too.

Avoid wandering through the code

The modern world is full of distractions: notifications from your phone, messages from colleagues, and dreaded meetings. I don’t have smart answers for handling these.

But there’s another kind of distraction: I start wandering through the code. I begin working on one thing, and two hours later, I’m changing something completely unrelated. Maybe I’m theoretically being productive and improving the codebase, but that bug I was assigned isn’t getting fixed! I’m “lost in the sauce”!

I’ve found two concrete ways to manage this:

Some programmers naturally avoid this kind of distraction, but not me! Discipline and deliberate action help me focus.

Make small changes

The worst boss I ever had encouraged us to make large patches. These changes were wide in scope, usually touching multiple parts of the code at once. From my experience, this was terrible advice.

Small, focused diffs have almost always served me better. They have several advantages:

I also like to make smaller changes that build up to a larger one. For example, if I’m adding a screen that requires fixing a bug and upgrading a dependency, that could be three separate patches: one to fix the bug, one to upgrade the dependency, and one to add the screen.

Small changes usually help me build software more quickly and with higher quality.

Skills that have been useful

Most of the above is fairly high-level. Several more specific skills have come in handy, especially when trying to build software quickly:

All of these are skills I’ve practiced a bunch, and I feel the investment has made me a faster developer.

Summary

Here’s a summary of things I’ve learned about building software quickly:

Everything in this list seems obvious in hindsight, but these are lessons that took me a long time to learn.

I’m curious to what you’ve discovered on this topic. Are there more tricks to know, or practices of mine you disagree with? Contact me any time. I’d love to learn from you!

Thanks to the anonymous reviewers who provided feedback on drafts of this post, and to tcard on Lobsters for a comment I incorporated.