Monday, 1 November 2010

Bad Program!

Below we tablulate some programming examples which would get you fired at a decent software firm, and the corresponding, all too common, spreadsheet equivalents:

Coding without planning:

A good programmer never simply opens Visual Studio and starts typing away. He thinks, he considers, he designs, he plans. He writes a specification.

Then he starts coding.

To do otherwise will almost certainly result in poorly designed, inefficient code which cannot be reused.

The spreadsheet jock opens Excel, pastes in a load of data and starts typing away.

Plan a spreadsheet?!? Are you mad? When was the last time you saw a specification for a spreadsheet?

 Which results in...

Spaghetti code:

Code which is badly written and hard to follow is called “spagetti code”, particularly a problem in older languages where “GOTO” statements could mean that execution might jump to an arbitrary place in the code at any time. A cell in a spreadsheet can reference a cell anywhere else, on another sheet, even in a completely different document. Calculation can (and does) happen forward, backward, left, right, leeward and windward and sometime straight round the loop. Trying to follow a calculation can be a nightmare.

 And when trying to follow a spreadsheet calculation one often encounters...

Magic Numbers:

Sometimes when reading through a piece of code you might encounter something along the lines of:

claims = claims * 6.283 

 What is 6.283? Why multiply claims by this number? Is it documented? Does the programmer still work here?

Getting to the bottom of this can waste hours or days before you eventually figure out that, somewhere further upstream, the number of claims is divided by 2π for some reason.

Or, less happily, the original programmer just typed it in by mistake and the company has been paying out 6 times too much in claims for the past seven years.

You know that cell in that spreadsheet where, in the guts of the computation, someone has typed

= 3345973 * 12 ?

The twelve could be an annualisation factor, but where did the 3345973 come from? Luckily someone has left a comment on the cell.

 “07/02 following phone call with JT. DM”

Thanks DM, that clears things up. If only we could find you, or JT, we could at least work out if 07/02 was February 2007 or July 2002.

Our example is closely related to...

No Version Control:

People making arbitrary, undocumented changes to code,
fixed bugs randomly reappearing,
incompatible branching variants,
unreliable testing, wasted time, money and early deaths due to stress and frustration.

A version control system is essential for delivering any but the most trivial of software projects.

Ok, maybe early death is an exaggeration, but frustration with the state of a firm's suite of spreadsheets has been at least partially cited by acquaintances of ours in decisions to switch jobs

No comments:

Post a Comment