Main Content

Build on what you already have with OO

Archive - Originally posted on "The Horse's Mouth" - 2006-08-17 08:29:57 - Graham Ellis

If I start recalling a "Goons" sketch, then I'll show my age .... but never mind. It was a RERUN that I saw ;-)

Spike Milligan is counting votes at an election. "Two thousand, six hundred and forty two". "Two thousand, six hundred and forty three". "Two thousand, six hundred and forty four" ...

"Would you like a cup of tea" - a pleasant young gent walks up. "Thank you" says Spike. Sound effect - tea slurping.

"Two thousand, six hundred and .....". "Two thousand and .....". Pause. "One". "Two". "Three" ...


It's a classic, and we all laughed. And yet, when we're programming, it's so tempting to develop code from scratch - not to build on existing logic but to redevelop something that's already been redeveloped. And that's why the Object Oriented principle of inheritance is so brilliant and efficient. Taking one class defeinition, you define a new class ... not from scratch, but rather in terms of specifying only those things that are added or changed.

If Spike had jotted down the number he was at on a piece of paper, he could have carried on so easily after his cuppa. Of course, it wouldn't have been funny, but then programming isn't funny.