Long (over 10 years) before I received my Ph.D. degree (a.k.a “Permanent Head Damage” or “Poor Hungry Doctor” by my interns) and thus immediately labeled as “Incapable of writing a single line of code that is not FORTRAN” I have earned my living writing code for quite big rather critical systems.
I worked with different programming languages, some of which I bet you never heard of, I used whatever needed to get the job done including punch cards and compilers that run on tapes, and I wrote a lot of assembly… and a lot of object code — I still remember some of the codes.
Since then the world has changed, punch cards, tapes, computer front panels .. are nowhere to be found, and the simplest smart phone is significantly stronger than any computer I used to work on back then, and it fits in a pocket i.o. taking up a room with
floating floor and air condition that freezes up your everything.
But one thing has not changes. High quality code is not created in-front of any screen.
High quality code is created while talking a walk in the park. That is thinking, and having peace of mind. The rest is merely typing.
It doesn’t sound like much, in fact – it doesn’t sound deep at all. But how many people really take the time to think peacefully away from their desk about the problem at hand?
It sometimes is a very hard thing to do especially when you are stressed and when the project is already late.
Try this – next time you need to write a program, just think about the problem you are about to solve for several hours, a day, two days, or even an entire week away from your desk (either in the park – or any place that gives you peace of mind) before you sit to write the first line of code (must be the first, after that you may already be committed to a wrong path).
It may be difficult to explain to your supervisor why you need to take a walk in the park, all by yourself exactly at the most stressful time of the project. But one thing is sure – thinking for two days before writing the first line of code will not slow you down. What will slow you down tremendously is writing a not-well-thought-of-code in two days — and then “debug” it for two weeks. And after that continue to debug it for three additional months, or a year, because you already put a lot if effort in it and you are “that close to get it done”… before you realize it was fundamentally flawed from the start.
AS an exercise try this:
I put in this page:
Fibonacci code — It is JUST Fibonacci running on Linux, nothing special about it. Perhaps the oldest CS exercise in the book, and now see if you can write a smaller / faster code while thinking and coding on the fly at your desk.
I didn’t, and couldn’t write at my desk without taking some quite time to thing first.
Note though that I do not think that this code is the smallest / fastest possible, in fact I know it is not, but I believe it is sufficient to make the point.
Thank you for reading, please let me know what you think 🙂