I tell stories to computers, as my friend Howard has put it.
This is what programming is: writing down the story of how a piece of information is turned from one thing into another, or how a set of data is to be interpreted, or how to paint a picture which shows the information to the user of the program. Sometimes I write programs that help other people write programs – indeed, there was one tool where I wasn’t just writing a program about programs, it was a program about programs about programs about programs*, which in my experience is about as abstract as it gets in software.
But still – the point here is not the occasional abstruseness of my day job, the point is that programming is story telling, and as such is close kin to writing fiction.
One of the most powerful tools in software is something called the use case. A use case describes something that the system does – a way in which the software can be used to perform some piece of work: open a file, for example; add a case of gin to the shopping cart; make the alien’s head explode. Where the power comes in is that you describe not just the the general feature, but the state of the system before the use case starts, and the ending conditions: the file must be present on the disc; the user must be on the distilled liquor page; the alien’s helmet must have been removed. You do not define how you get from one state to the other. This is all about what the user sees, and maybe what long term state changes. The implementation is not specified.
When I am laying out a novel, I effectively write use cases for my chapters. Each chapter gets a note on who is in it, what the starting conditions are, and where the chapter needs to end. Unless it is important to the plot, I leave the location loose, and I may add a couple of things that need to happen if they are not implied by the end state, but that’s all. Out of that looseness comes the discovery of the setting and the invention of minor characters that I enjoy so much.
Of course, the deeper truth about programming is that although you are telling the computer what to do, you are really writing the story for the next person who touches the code – so we are telling stories to each other using bad spelling and too much punctuation.
[*] for the record, it was a tool for writing descriptions of reusable diagram components which were then used to create diagrams which could then be used to generate application code.