JOHN MEANEY

31.12.10

THE DUCK-BILLED PLATYPUS RULE

It goes without saying but, er, let me say Happy New Year, hope you're having a wonderful holiday, and remember that optimism is a learned behaviour, and that humans can learn to do pretty much anything. (It's exactly when the going gets tough that optimism is the best tool in your mental toolbox.)

Now the part of me that teaches software engineering is spinning a bit due to, well, writing full time. So let's get philosophical...

I'm talking about categorizing the world.

One of the things that I mention when Class Diagrams pop up is what I call the Duck-Billed Platypus problem. You know what I mean - when Victorian zoologist types (and their predecessors) categorized living organisms, they created large categories defined by multiple shared characteristics. There was a group with spines, body temperatures controlled by negative feedback, and bringing babies to term inside their bodies, after which the babies were nourished via external maternal glands. There was a group with spines, scaly skin, lacking the thermostat mechanism, bringing their young to term inside external containers with thin calciferous shells.

And then the Duck-Billed Platypus came along...

Creating software systems involves modelling the Real World™ (the requirements) and the new system (which is also a Real Thing™). So we're talking about perceiving and making sense of the world...

And when it comes to designing a new system, one of John's Rules goes like this: every project contains a duck-billed platypus.

<geekTalk>
So what do I teach? In the context of UML and OO, I'll point out the benefits of holding back the use of inheritance, and using aggregation to add the various characteristics of classes. There are some useful design patterns here, like separating out behaviour with the Strategy Pattern, or even using the Decorator Pattern (usually used for plugging in varying, cumulative functionality, as in the Lego-like build-your-own-i/o-streams of the core Java i/o API). And most people's first pattern, the Composite, still makes me smile at its recursive simplicity.
</geekTalk>

Even if you think you've got the categorization nailed (for all time? really?), then polymorphism and inheritance contain subtleties. In a Formula One racing game, if your definition of Car allows a start() operation to run when it's (virtually) raining, then the race controller expects this behaviour. A developer should be able to add a new subtype of Car in version 2.0 (if we're using inheritance) without the controller component batting a (virtual) eyelid.

In other words, if you're a real software engineer, and you specify the pre-conditions of an operation (what must be true to allow it to execute) and the post-conditions (the results, including range of values) then any subtype must match the pre-conditions of the parent (or be more open, and be careful how you understand that), and produce a result that is within the range of results produced by the parent (a narrower or equal range). For example, try creating a new subtype of Car whose start() operation throws an exception of a kind not thrown by the parent. Good luck in getting that to compile....

As an aside, none of this captures the dynamic aspects, which you also need to model. Some people think only in static categories. I have a highly intelligent friend who looks at élite marathon runners and thinks (I believe): marathon running is for thin people; I am not thin; I am not a marathon runner. All of which is true, but not necessarily eternally. (Try adding the world 'yet' to the end of the previous sentence. Or better, think about dynamic processes. If you jog a little today, and carry on doing it 6 days a week for the rest of your life - increasing to the level appropriate for you - then if you get to the stage of running a hundred miles or more every week, just what kind of physique would you have then?)

(Aside the second: what if you thought of optimism as a process, defined by an erect spine, chin held up, a hint of smiling, a steady gaze...)

Now if I'm designing an ATM, I expect it to talk (via many layers of indirection) only to bank accounts. And a classification system of bank accounts is straightforward, surely. Or is it? In the US, having fed my card to the machine, I get asked whether I'm taking money from my checking account or savings account. Huh?

That's a choice of two accounts for one card, which is impossible in the UK, using terminology which I have to translate in order to understand (current account or deposit account, realizing that 'checking' relates to cheques, not monitoring).

Then my American friends come to visit, and they can't pay for goods in shops in the normal European way, by sliding their card into the chip reader and then entering their 4-digit PIN... which is why our machines also have to support reading the magnetic strip, an outmoded 20th-century technology.

Still, it's not too hard to make the technology forgiving of ill-defined categories... in such a small conceptual domain.

Now here's the thing. I teach techniques for categorizing reality when things get slippery, but there's a massive question: when should we stop trying?

Or, when do you sit back and let humans do the understanding - individually and cooperatively - instead of trying to build 'awareness' into the software?

That's the subject of the funny and insightful Ontology is Overrated by Clay Shirky. SFnal jokes included. Enjoy!

And enjoy the heck out of 2011...

13.12.10

AUDIO FILE...

I've put a simple link to the audio file containing the beginning of Edge, as narrated by me. Check out the media page. The embedded media player may not behave, but the file link should be fine.

Let me know about the quality. I need to record it again with a better mic, I think. (Workmen, tools, etc.)
REALITY™ BITES

Last Eastercon, I was on a panel discussing whether writers should blog and otherwise flaunt themselves in the virtual world. Besides revealing that I'd described Joe Abercrombie as bitter and twisted on his own blog, I also mentioned that full-time writing at home is a very unhealthy occupation. Certain prolific bloggers are not exactly the picture of good health - I'm not boasting, not after the snail-pace runs I've put in recently. Cost-benefit analysis might recommend going out for a long walk, if not to a gym, during those blogging hours.

Just to prove we're not post-Singularity yet, you can't shop online in Scotland now, because the weather's so bad the deliveries won't get through. You can sit in your cosy home with your cosy laptop, but you can't manipulate all of reality with your keyboard. (Although an attack on the power grid might have some effect, admittedly.)

On the other hand, there's no such thing as a true laptop computer yet. A true laptop computer goes away when you stand up. See? I'll be first in line when they hit the shops.

2.12.10

OLD SCHOOL

Felt dreadful yesterday - simultaneous deadlines and poor planning kept me working long hours with not enough sleep. Two days in a row off training (one rest day a week is plenty), and I was feeling tired at the end of a third day with little physical movement. Unless you've been working on a building site all day, that tiredness might be real but it's symptomatic of stress more than physical exhaustion. So it was on with three shirts and the ancient ski-jacket I use for cold weather training, and never mind that it was 10:45pm. Up the garden to my below-freezing dojo/gym.

Padded up like the Michelin man, I'd planned on some light calisthenics to warm up, followed by a slow-tempo weights session. But once inside, I realized I needed speed and effort, so I made up a routine (just a variation on one of my usual routines), fixed it in my head, then got to work:

10* x (25 x Hindu push-ups; 50 x Hindu squats; 10 x burpees)
4 minutes static Wrestler's bridge (neck bridge)
5 x (25 x pulldowns ; 25 x ab crunches)
then I worked karate drills - 10 different combinations - followed by the single-set finisher:
50 x 2-hand kettlebell swing

Some stretching, and I was done, and not a cobweb in my head.

My new training motto: BUSTING YER ASS FEELS GREAT - AFTERWARDS

Low intensity exercise bores some people; high intensity work demanding full concentration is very different. And it doesn't require a big budget, only heart (and maybe a few square feet of floor space). As for running, the (rare) independent research on running shoes apparently indicates that expensive new shoes cause injury (by over-protecting the foot, making it weak and unable to cope with inevitable twists or other stress). Cheap battered shoes are better. Injuries were rare in the old days before hi-tech footwear.

Something else occurs to me about keeping things simple. Running routines are usually based on EITHER deciding in advance how far you're going to run OR how long you're going to run for. In other words, fix one number and don't bother about the other. (Or else measure it afterwards to determine the quality of the workout you've just had.) For the circuits above, I'd determined the numbers, so I didn't bother about the time - I used my judgement on rest times between circuits (practically zero for the first 5 circuits, and always resuming work before my breathing had calmed right down).

Right then. Back to work.

* - to keep count of circuits, I have laminated cards with numbers on: I move a card at the end of each circuit. In hotel rooms, I use coins or whatever else is in my pockets.

† - pulldowns done with a high-tension band fastened to a ceiling beam. Indoors in the house, a gi belt looped from a doorway chin-up bar (the "indoor gym" variety just fits in place without screws) would have let me do horizontal rows for a high-rep back-and-biceps exercise. Or I could have just opened a door, taken hold of the door handles, squatted and leaned back with my feet either side of the door, and performed doorknob rows: no equipment necessary.