This is so soothing.
This is so soothing.
that scrape tho. 🎧 recommended👂🏼〰〰
I’ve used the term “Documentation Driven Development” in conversation a few times over the years, and people usually seem to just get what I’m talking about. It’s like “test driven development”, and every bit as disciplined, but for docs instead of tests. I certainly did not invent this concept, and it’s very simple.
I also don’t think that many folks realize just how serious I am about this. And the repeated truism that bad documentation is the worst thing in open source seems to indicate that it’s not being evangelized enough.
Here’s the process in a nutshell. This is how I usually write JavaScript modules, but it’s also how I approach designing product changes at npm, from small tweaks to entire new product lines.
Before anything else, write down what the thing is in README.md. I use markdown, but any portable plain-text format will do. This takes three parts:
Note: the thing doesn’t exist yet. You do this before it exists.
Copy the example code into a test file. (Basically just do const t = require('tap') and throw some asserts around it.) For things bigger than a single JavaScript module, you can also copy the various points of the description into user story issues for QA or whatever process you use to verify that the thing you built is actually what the docs say it is.
Now you are ready to write the code that does that thing. Whenever it seems like the usage example was wrong, update it. As it becomes more clear what it is and how it works, keep the docs in sync with the code and the tests. The goal is to maintain 100% test coverage and 100% documentation coverage.
When you want to make a change to the thing, first update the docs and then write the code and the test. It doesn’t matter if the test comes along with the code or if you write the code and then the test, but the docs should absolutely be written before any implementation or test code.
If you ever find yourself thinking “It’s done, I just need to update the docs”, then you’ve violated this process by even having that thought. Not only is it not done, but you might’ve done the wrong thing.
It’s fine to write some code to try to figure out what the thing should be. But that is experimental scaffolding, and should not be thought of as anything other than useful garbage, like a sketch on a napkin. Maybe it can be turned into something enduring, but that starts with docs.
Writing clear prose about software is an unreasonably effective way to increase productivity by reducing both the frequency and cost of mistakes. Just as with good tests, it helps ensure that your program does what you think it does, and that you’ve thought it all the way through.
This unreasonable effectiveness of writing things down comes from the fact that a human brain’s working memory size is absurdly small. While it seems that we can hold a lot of things in our mind at once, it’s only by constantly swapping to long-term storage and ignoring increasing numbers of trees in order to see the forest. A written document does not have that problem. We can fully off-load significant chunks of thought with hardly any data-loss, allowing us to think slower and more carefully while still covering a huge semantic surface.
I don’t like using inline comments to generate interface documentation, for the simple reason that my sole focus must be on the user mental model when writing docs, and that should lead the creation of the thing. If I’m writing documentation and implementation at the same time (or even in the same format), I’m naturally inclined to create a “nice implementation”, which may or may not be an interface that meshes well with the user’s mental model.
The design of how a thing is used limits the implementations available, and vice versa, so whichever is done first will tend to limit the scope of the other. It can be a bit of extra work wrestling the code to fit into the constraints of a user’s mental model. But it’s work you only have to do once, as opposed to the ongoing slog of handling bugs and issues that result from trying to shape user expectations to fit an implementation.
I get asked for career advice semi-regularly by people just starting out in tech. I don’t know to what degree I’m qualified to advise anybody, but the advice is always very different and specific to somebody’s circumstances. However, there is one recommendation common to everyone: be useful.
By that I mean: if you pick a company and get hired for a job, do that job. If the job changes or the company changes, then do your new job, or quit. But don’t try to do some other job. Be useful. Be the person your company needs you to be right now.
You’d think that would be obvious, but the opposite happens all the time. People get hired thinking they’re going to be doing task A, discover there’s more task B to be done, and declare “that’s not my job”. Okay, sure, it’s disappointing you don’t get to do A. But the company is not going to create a job for you doing A. Either you do B or you quit, or they will fire you.
Another way it happens is when, through the best of intentions, somebody attempts to grow in their career within a company. They’re doing A, they want to be doing B, they start picking up any B that happens to be lying around. That’s great! You should do that. But not if it means A doesn’t get done. When the company is big enough that you need two full-time people doing A and B, you can pick which one you do. But not before then.
Being useful is another way of saying “respond to market demand, not what you guess”. I thought I was going to be a Java developer in 2005, but Yahoo hired me to be a PHP developer. I could have said no and worked at a bunch of other Java companies, but that would have been a bad idea. Once at Yahoo I was supposed to be writing desktop software, but the team needed a website, so I built a website. Then there was a reorg and I found myself in another part of the company expecting to still be a web developer, but they needed a DBA, so I became the DBA. Over and over in my career, I have done the job that needed doing, and it’s made me valued at my job and more valuable as an engineer.
Right now I’m a COO. I don’t really enjoy talking to lawyers and accountants all day. I’m not jazzed about spreadsheets, generally, though they have a certain quiet satisfaction. But it’s the job that needs doing, and doing it is making the company better. It’s making me more valuable – if I ever decide to do a startup again, I know a lot more about finance than I did before – and it’s entirely an accident.
All that said, you don’t have to stay in one job forever just because it needs doing. If your career isn’t growing, by all means quit and find a job at another company. But don’t try to create that need at a company that doesn’t have it.
Do the job that needs doing. Be useful. And it will pay off.