Friday, October 26, 2012
Code Complete: High Quality Routines
Maybe this is just me. I'm a huge fan of working on things in a larger context, but I know that that's not everybody's cup of tea. It has been argued that some people like to read the abstract theory associated with things before encountering examples in context. If you're one of these people please do get in touch and let me know. I'd like to learn more about your thought processes.
Anyhow, just as an example of some mixed routine practices from things I was programming today, I created one short routine
and grabbed another from StackOverflow:
Now I've got a really awful vanilla name for the routine I created (processForm) and all sorts of hacked together pieces of things, but that's partly a reflection of the "tracer bullet" methodology I was working on here, which was to get something that would take a form submission from a Google App Script generated html page, and enter the resulting data into a spreadsheet as described in this StackOverflow post:
At least I can be pleased that both routines are relatively short and have a very small number of input parameters. I think that both could be improved with refactoring. I'll present that in a future blog post, but right now I know I and my students are going to be using this code every week to support assignment submissions, and getting a feel for getting this working in Google App Scripts was the top priority that trumped every other consideration. Not the best programming practice perhaps, but let's see how I can iterate and improve this over the next few weeks.
Google App Scripts really rocks, but I'm still trying to work out how to version and share all this stuff effectively so we can see the software engineering and systems analysis issues in the context of this larger project, as described in this other SO post: