OK, I think I’m learning something about how to manage my limited amount of skill and time to do leisure-time programming for myself. “Bottom-up programming” is important.
I just decided to do a little gallery app for the umpteenth time; in PHP. I know PHP well enough that I don’t trip over the big gotchas too much, and I know where in the documentation to look to find the functions I need. It’s also dead easy to deploy (“put the PHP file where your web browser can find it.”)
Following impulse, I decided to do this all at my own pace, and in small, elegant pieces. I first learned about the power of tiny, elegant functions and methods when I was learning Smalltalk, and my frequent mistakes sent me into its debugger, which often, to my surprise, took me into the guts of the code of Smalltalk itself. Looking at the way Smalltalk itself was written, I found that one- or two-line-long methods weren’t at all uncommon.
The idea there is that methods, functions, whatsoever serve the purpose of conceptual chunking. And the smaller the chunks, the easier they are to manipulate. Ideally by looking at the name of the method, you will know exactly what it does. So when it’s used in the code, it documents itself.
I don’t get to do that too much at work. 100-line functions which do three dozen things are the order of the day, and it’s usually not within the scope of what I’m doing to break them apart at all. So when I can actually do that kind of programming, it’s kind of fun.
Oh, where was I? Yeah. So I decided, for this little bit of coding, to do everything in small chunks that I totally understood. And I had a heck of a lot of fun, and I ended up with a nice little thumbnail-maker and that sort of thing. There’s not much to it yet, but if I keep working on it, which I might, I’ll end up with my own personal version of the dozens of little-PHP-gallery-makers out there.
And I actually enjoyed it, and it wasn’t intimidating or wearying. I’m proud of the code that resulted.
Taking things a very small, doable chunk at a time is peaceful and pleasant. It’s one good way to be creative.
Maybe some of the programming things that intimidate me intimidate me because I try to take on too much at once, and don’t do it piece by piece, making sure every small piece is well within my ability and attention span.