Today I had a few jobs to do around the house. One of those jobs was to replace a light fitting and some switches.

Electrical stuff always make me a little bit nervous. I’m fairly confident that I can do it, and if I get it right first time I’m happy. If things don’t go to plan though, then I start to think very carefully about what I’m doing, and I certainly don’t resort to guessing, yet I’ve seen (and am occasionally guilty of this myself) people do exactly that when some code they’ve written doesn’t behave as expected. For example, if a conditional isn’t working as expected people start to guess, to swap a > for a < here and there without any real thought.

The before picture – so if I mess it up I have a place to get back to :S

Guesswork is certainly not the approach that I would take with electrical wiring, and it shouldn’t be the same with programming either, although for entirely different reasons. The fact is that there are ways I could mess up the wiring, yet my wiring might appear to work, and the same is true of programming. The consequences of guessing at the wiring are potentially far more grim, but guesswork when programming, and particularly when learning to program can also be potentially harmful. Not only is guesswork likely to introduce bugs later on, but focussing on the desired output – a program that *appears* to work – distracts from the learning of why that program works.

That’s why programming should be more like wiring! 🙂

Advertisements