Not Just Solving the Problems That You Get Assigned to You from a Textbook
Posted by Richard on Monday, 19 June 2006Joey deVilla links to (and helpfully summarizes) 15 Exercises for Learning a New Programming Language. The second exercise covers writing an application or script that generates the Fibonacci series. Once, in a fit of boredom—either that or some misguided attempt to learn programming "the proper way"—I dug out my old C++ book from university. Yes, I took Computer Science 101 in the days just before the universities started teaching Java in its introductory classes. One of the exercises was to program a function that shows up to x numbers in the Fibonacci series, forever made famous in my head in an episode of Mathnet back in the day on PBS, part of the mini-series that included the talking parrot ("one one two three five, eureka!"). After trying a recursive function—something I've never been able to do unless the algorithm was given to me (something about learning how to write sorting routines, which I've long forgotten so it's a good thing programming languages come with them built-in now)—I gave up.
To my relief, I had earlier seen a comment on Slashdot recommending programmers learn by solving their own problems. (And by seen on Slashdot, I mean seen on Seen on Slash.) The problems I needed solving involved things the various CMS platforms couldn't do out-of-the-box (from Blogger to Movable Type to WordPress to Drupal, all needed a little PHP help to make things just right). With the last two, I looked at the source of plugins and modules, respectively, to reverse-engineer how established programmers did things. Not that I claim to be in any way typical in how I learned to program, but there are others who looked at the CMS' code and APIs and improved their programming skills. So any advice on learning a new language that doesn't include "use libraries and APIs" (why duplicate effort?) and "reverse engineer code from projects and programmers you respect" should be the top two items. I could use a healthy dose of math and statistics to buttress my intermediate PHP scripting level (my highest level of scientific thinking is high-school at best). Though the Slashdot commenter probably underestimates the value of exercises (hockey players get better at skating backwards by practicing skating backwards, and initial skating lessons help in learning proper technique and habits early), solving your own problems is, for many, a more effective way to learn, not just solving the problems that you get assigned to you from a textbook.
A week passes after writing the above and Joey links to some more exercises, which “seem a little more "real world"”: calculations, data structures and libraries. I came close to writing an RSS feed creation library before stumbling on FeedCreator.class.php. I had to hack it to allow for the creation of multiple <category> elements (checking to see if it was passed an array or a string). The moral of the story is that sometimes problems are already solved for you, but you sometimes have to go the last mile.