Good programming is notoriously difficult to teach. Programming books generally all start out in the same way: "Here is an example of an X, and here is an example.". Teaching the building blocks is easy. There are only so many. The hard part is teaching the consequences of each choice. The common advice is to write a lot of code to get good. This is necessary but not sufficient. To learn we still need to decide what code to write, and how to improve that code.
We will explore the closely related field of writing to get advice on improving our craft. In many ways programming is like writing. Both are centrally concerned with getting your thoughts down into an easily communicated form. We find both hard because our ideas are densly cross-linked whereas text is depressingly linear. The infinite variety of ways in which thoughts can be represented in text makes learning the art of writing, as well as programming, difficult.
Thankfully, Benjamin Franklin recorded a method that he used to develop proficiency. As evidence of his writing prowess, we need only look at the Amazon Biography best seller's list. His biography is still one of the best selling books after x hundred years. If that's not proof then I don't know what is.
Benjamin developed his method in his early teens and worked hard at practicing his craft. Here is the exceprt with a few added line breaks for legibility.
About this time I met with an odd volume of the Spectator. It was the third. I had never before seen any of them. I bought it, read it over and over, and was much delighted with it. I thought the writing excellent, and wished, if possible, to imitate it.
With this view I took some of the papers, and, making short hints of the sentiment in each sentence, laid them by a few days, and then, without looking at the book, try'd to compleat the papers again, by expressing each hinted sentiment at length, and as fully as it had been expressed before, in any suitable words that should come to hand. Then I compared my Spectator with the original, discovered some of my faults, and corrected them.
But I found I wanted a stock of words, or a readiness in recollecting and using them, which I thought I should have acquired before that time if I had gone on making verses; since the continual occasion for words of the same import, but of different length, to suit the measure, or of different sound for the rhyme, would have laid me under a constant necessity of searching for variety, and also have tended to fix that variety in my mind, and make me master of it. Therefore I took some of the tales and turned them into verse; and, after a time, when I had pretty well forgotten the prose, turned them back again. I also sometimes jumbled my collections of hints into confusion, and after some weeks endeavored to reduce them into the best order, before I began to form the full sentences and compleat the paper. This was to teach me method in the arrangement of thoughts.
The Benjamin Franklin Programming Practice Model
- Find a program that you greatly admire and read it.
- Takes note on the roles, inputs, and outputs of each major component.
- Take notes on how the components interact.
- Rewrite the program.
- Compare your code with the original.
- Note where you can improve and study acccordingly.
Don't just write more programs. Super charge your abilities by studying great programs, and then trying to imitate them.
How do you get better at programming? Tweet me (@practicepython) your practice methods. I would love to hear how you practice our craft of programming.
Oh and if you found this helpful, please share it with your friends. Sharing is caring :]Comment