Main Content

And and Or illustrated by locks

Archive - Originally posted on "The Horse's Mouth" - 2010-01-17 20:41:12 - Graham Ellis

Lisa and I came across this impressive array of locks on what we have since learned is probably the back gate to the National Grid's Lacock Switching Station, about 3 miles North of Melksham. [picture/details]

Our first reaction was "wow - that must be REALLY secure - what are they doing in there?" as we imagined a group of five people all having to turn up and the same time in that bleak and desolate spot, with high power electricity pylons humming above to get into the place.

But a careful look at the picture later leads me to think that if any one of those locks in undone and the holding bar that it locks is removed, the over bars will slide to the left and the main bar can be removed; rather that been a very secure site indeed, there are simple five locks there so that the electric people, the water folks, the fire brigade and two others (the local council have powers of entry almost everywhere, so they probably have a key, and perhaps the ambulance service) can each gain access without having to wait for the others.

It's very common when writing code to link up conditions using and and or operators - in some languages written as && and ||, and it's quite tricky sometimes for newcomers to get their head round the enormity of the difference between then. I think I'll use this picture on future courses.

I have concluded that locks probably do work with "or" not "and" for another reason. The chain looks pretty flimsy, and a good pair of bolt cutters would get you past the gate in a jiffy. It's highly unlikely that such a lowgrade chain would have been used if the security of five locks all to be opened at the same time HAD been what this mechanism was about!