Recently I reread Clean Code by Robert C. Martin once again. It’s actually a book that I would recommend any software engineer to read from time to time. Apart from its obvious content about the crafting of software that is easy to read it sparked another thought. Multiple time in the book there is talk about the different levels of abstraction that source code should contain and about how good code reads like a well written story.

Thinking about that I figured that actually there are a lot of similarities between the craft of writing and the craft of software engineering. Actually I’d like to suggest that software engineers do nothing else than write about a problem they want to be solved – just in a language that a compiler (or interpreter) can translate into something that a computer is able to read and understand.

Based on that idea I came to realize that there is also a high grade of similarity no natter whether you are writing a story or you are writing software. In both areas you actually should write in a very similar pattern. In the end you should structure your writing so that it carefully leads your reader into the matter step by step:

In the beginning there is an introduction. You set the scene to open the mind of your reader for what will happen later on. Page after page the reader uncovers more details of the text – and if it is well written he or she will not be overwhelmed by the complexity of your story. In the end the full context of your story is known. The reader will be aware of all the different plot lines and how they were resolved.

Reading the paragraph above you will most likely agree that this is true for a well-crafted book, article, paper or whatever writing you’ll recently had in hands. But does it also apply to source code? I think it does. What applies to the content of your story also applies to the details of your code. By slowly descending through decreasing layers of abstraction you can evoke the same feeling when writing software. In the end, what is writing code else than writing a description of what a computer has to do, but in a different language?

So how can you benefit from writing stories? By writing stories, no matter if short or long, you learn to structure your thoughts. If you are capable of writing down what is going on in your mind so that others can understand it you will automatically increase the readability of your code. This is something you can train!

Now, start to train. Take a paper and start writing. No matter what you write about. Think of something that happened lately or a topic you like and start writing down your thoughts. Try to rework your text until you can present to someone else to read through it and give you feedback. Once other people are able to follow your thoughts along your writing you learned to structure your mind – and that’s something every engineer profits from!