Writers write. They say that if you want to be better at writing the only way to do it is to sit down and write. There is no other way. Reading books on “becoming a better writer” and going to “inspiration” workshops won’t help; there is no manual on how to become a famous writer. Because if there was, then anyone could become a great writer, publish a great book, and make a lot of money. And most of the writers I know, are far from millionaires.
The only way to get better is to write. A lot.
If you are a programmer - you write. You write a lot. You write every day. You write at work, at home, in the morning, in the evening, and sometimes even when you sleep. Whether you write for work or for fun, is irrelevant. Most writers don’t write at “work” and then at home. Their writing consists of about three hours every day (unless they are journalists of course). Compare that to the fifteen hours for most programmers.
Isn’t it curious then, how being a writer is regarded so highly by many people, as being a hard occupation? Nevertheless, writer is a much older occupation than a programmer, so we could probably learn a thing or two from them.
Workday
The very same work day of three hours per day, mentioned earlier, is not just a random number, made up randomly by writers because they are lazy. It is there exactly because that is the extent of how much creative work a human can do to their full potential during the day. So, when you say that you work ten hours a day, how much work are you really doing?
Elementary principles
Here I will blatantly rip off the writers’ bible The Elements of Style, which details some of the core principles that most writers must follow. While these rules are not agreed upon by all, it is the consensus that if you want to break the rules, you must, at least, know what they are.
Choose a suitable design and hold to it
Writing, to be effective, must follow closely the thoughts of the writer, but not necessarily in the order in which those thoughts occur.
Here, programmers, perhaps, have an upper hand, as setting down their thoughts in code is arguable easier (at least easier to check if what they wrote meets their expectations) than it is for writers to set down their thoughts on paper in a clumsy and imprecise language, such as English. In the next part, we are probably as much to blame as anyone else:
The first principle of composition, therefore, is to foresee or determine the shape of what is to come and pursue that shape.
How often have you plunged into coding (“writing”), without first thinking of what it is you are trying to achieve, only to find yourself, two days later, lost in the heaps of methods and classes that have become so intertwined that you can no longer understand how your masterpiece works?
This next piece of advice, took me about ten years to understand.
The position of the words in a sentence is the principal manes of showing their relationship. Confusion and ambiguity result when words are badly placed. The writer must, therefore, bring together the words and groups of words that are related in thought and keep apart those that are not so related.
I was always taught to break up my code into functions; sometimes even put a bunch of functions into a separate file. The focus was always on breaking code into smaller pieces, emphasizing reuse and avoid copying. But nobody ever told me that I should group related functions, variables and other things close together - so that they would be easy to read, without jumping from one file to another. After all, if you are reading a novel, you can’t imagine jumping to footnote and then back over to main text - this would distract from the main flow of the story! So why, if I am reading you code, should I jump from one file to another and another to figure out exactly what story you are telling me?
Conclusion
While I could go on and try to stretch this even further, I won’t. What I am trying to say is that if writers, who were around for thousands of years, still can’t get their stuff right - need to practice their craft every day and read rule books to not forget how to do what it is they do - how can such a young profession as a programmer claim to be perfect in it’s practice? You cannot afford to stop learning and refining the way you learn. And maybe, take a few tips from other older professions. Unless, of course, you want to stay a journalist all your life.