Saturday, March 21, 2009

Paper Pushing

Way back when I got started in programming, my high school did not have any computers, of any sort.  So the programming was done on coding sheets, which were sent into the school district data processing facility, where some data entry clerks typed them in, presumably on cards, and sent the batch job to be processed.  If we were lucky, everything was correct and we got back a result printout.  If we weren't, we got back an error sheet and had to examine the code again to see where we went wrong.  Usually it was a syntax error of some sort, so we re-wrote the coding sheet and submitted it on the next batch.  I had one program that appeared to be un-typable - every clerk managed to typo something every try I made - the teacher finally let the program pass without running.

The next semester we got 3 Radio Shack TRS-80 computers, and we were freed from having to do coding sheets - until my college course in assembler, which was on punch cards - not a fun semester.

So for many years, I've been coding at the keyboard.  But when I have a particularly hairy issue, I find myself going to a blank sheet of white paper and pseudocoding my way into the solution.  I firmly believe that there is something visceral about writing that makes us more attentive to details.  There are others who have a similar philosophy.

On the other hand, I've also fond that in some cases, typing is faster when I'm trying to get an idea out of my head and into a recorded form.

What do you think?  Is writing code a quaint habit of old-timers, or a return to the core of the discipline?


Technorati Tags --
, , ,

Monday, March 16, 2009

Too Much Choice

An interesting point about choices.
One of my dislikes of Perl is this very thing - lots of way to do X leads to programs that use every way to do X in them.

One of the ways that choice makes our jobs harder is that every option needs to be validated somewhere in the code.  Often this gets translated into masses of checks for all the options at every point of action.

Instead of this, you should strive to have things checked at the earliest opportunity, and then have the rest of your code assume that anything past the checks is valid and right.  This limits your exposure to change, and makes the rest of the code flow smoother.  It does tend to collect your checking code in the UI (or the interface to the UI), but it's a lot easier.

This also applies to the UI - don't give the user every option if they aren't all valid.  Trim your menus of unactivated features; hide the checkboxes of custom features for the other customers.

Technorati Tags --
, , ,

Sunday, March 15, 2009

Drowning In Code

Sometimes you have to work on old code.
(pause as the shock and cires of "Heretic!" die down)

Since not everyone gets to write only new code, you'll have to face this task many times in your career.
Here are two tips on how to approach it.

They both assume that you have limited documentation, obviously, since they promote looking at the code as opposed to looking at the documents; this is better anyway, since we all know that the docs are least likely to be accurate (followed closely by comments in the code)

Another good way to become familiar with the code is to look for something redundant that you can encapsulate into a method.  This can lead to significant code reduction, making it easier for you to understand the remaining code.

Technorati Tags --
, , ,