Functional Decomposition

I have to see the program working in my mind as I write. Modern scoping makes it easy to write little functions of local scope that say what I mean to do.

A friend was amazed that I wrote functions apr and may in a test suite working with dates. Java's Date constructors are a confusing mess. I could say apr(15) or may(26) and get on with my business.

There is a confusion among programmers that the tools of their trade are to be applied only to their assigned problem. Every abstraction must be in service of the customer. With local functions I'm happy to abstract what I'm doing in the moment without any need to generalize beyond my immediate need.

Macros served this purpose for the assembly language programmer and have been raised to high art in lisp. I'm talking about something much simpler. A handy function or two at the bottom of the page.

Javascript seems to encourage this and coffeescript even more so. I chose tiny functions in the latter when rewriting programs I'd written in high school. See Craps Dice Game