Thoughtful Programming

Thoughtful Programming

This is a work in progress concept.

Thoughtful Programming is a loose term that applys to any paradigm or technique that encourages deep thought about a problem before writing any code.

Any half-decent programmer understands that actual coding is the easy and fast part. It is the thought process that goes into the lines that is the time consuming and difficult part. This distinction separates programming from coding.

In my experience, I've found that once code has been written, it is very hard to unwrite it. More often, code is a ball of clay. Once it exists, the best you can do is mold it to fit the demands of the day. If you are building anything remotely worthwhile, it is helpful to stop and think about things.

Modern-day compilers do not help with thoughtful programming. They are insanely fast and deliver results faster than we can think. Because of this, it is easy to adopt a meandering "guess and check" approach to developing a program. We all do this. I still do this. It's convenient and fast. But it is still sloppy. When you find yourself throwing code at a compiler and seeing what sticks, you are in a bad spot. Thoughtful programming breaks the compile-and-check loop, and gets people to actually think about what they are doing.

The literate programming paradigm is a good example of a tool for thoughtful programming. It allows a programmer to think about and structure the problem using natural language structure. A programmer could, for instance write out the entire program in plain English before writing a single line of code. Said programmer in this instance would be a thoughtful one.

Literate programming can also provide a subjective metric for thoughtfulness. It can difficult to determine how much thought has been put into a given line of code. Maybe that line was put in place after days of debugging. Maybe it was a quick hack for an intense deadline. Sometimes they can look the same. Prose in a literate program can be a barometer for code quality. If it looks like well written couple of paragraphs accompanying a couple lines of code, it's probably an important part of the program that the author put a lot of time into. If you see typos and things that don't make a lot of sense, it's probably not the greatest quality code either. I call this *proof of thought*.