daemonl

In case you were wondering...

Extended Analogy 1

tl;dr = function.

I am going to (attempt to) describe OO programming in terms not related at all to programming and computers. My hope is that it will be easy to understand, and clearly written. I'm not sure if it will serve any other purpose. It will probably contain the words 'consider a' quite a few times.

Way 'back when', before computers had power plugs, 'computers' were people who worked on mathematical production lines, calculating small parts of larger calculations for... whatever needed a large calculation done. (Astronomy etc) (No, Really)

They would have a set list of calculations to make. Given a set of numbers, they would perform the calculations in order, then return one or more numbers to their boss.

These workers were not 'dumb workers' in any sense that suggests they weren't intelligent, in fact this dude was a computer who first calculated the height of Everest. In the sense I require for this analogy, they are 'dumb workers' who do exactly and only what's on the 'task sheet' in front of them.

You'd think that since the invention of the electronic automatic computer we would have completely new and funky ways of organising tasks. Not so much - it turns out that this is a pretty good way to do things. In programming, this 'task sheet' is usually called a function - A list of calculations, given some inputs, which produces an output.

Now the output never goes to waste, of course. Sometimes the output is the final product - say, the position of Mars at midnight on the 5th of March 1682, or it might be used as an entry point for another task sheet (/function).

To organise all of the task sheets, there would be a master task sheet which says what other task sheets to work through, and how their inputs and outputs all link up.

And in modern programs, that master sheet is called... a program.

There's clearly a heap more, but that's all a program is, a list of things to calculate.

Stay tuned for more hair-raising analogy!