About

This is the archive page for Head of the Kyu. Click to go to the frontpage of this site.

Last Comments

Ben (Breakthroughs and…): Here is a strange observa…
Carl Manaster (A handy heuristic…): Note on the comment syste…
Carl Manaster (A handy heuristic…): Let’s try that again… www…
Carl Manaster (A handy heuristic…): I once wrote a little vis…
Nico (A handy heuristic…): C# can have multiple clas…
Nat (A handy heuristic…): “an XP project is suppose…
Jim Bullock (A handy heuristic…): Are the class (or whateve…
Ģirts Kalniņš (Head of the Kyu): good to see you back.

Calendar

« July 2008
S M T W T F S
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    

Archives

Next Archive Previous Archive

01 Jan - 31 Jan 2007
01 Oct - 31 Oct 2006
01 Feb - 28 Feb 2006
01 Jan - 31 Jan 2006
01 Nov - 30 Nov 2005
01 Sep - 30 Sep 2005
01 Aug - 31 Aug 2005
01 Jul - 31 Jul 2005
01 Jun - 30 Jun 2005
01 May - 31 May 2005
01 Mar - 31 Mar 2005
01 Feb - 28 Feb 2005
01 Jan - 31 Jan 2005
01 Dec - 31 Dec 2004
01 Nov - 30 Nov 2004
01 Oct - 31 Oct 2004
01 Sep - 30 Sep 2004
01 Aug - 31 Aug 2004
01 Jul - 31 Jul 2004
01 Jun - 30 Jun 2004
01 May - 31 May 2004
01 Apr - 30 Apr 2004
01 Mar - 31 Mar 2004
01 Feb - 28 Feb 2004
01 Jan - 31 Jan 2004
01 Dec - 31 Dec 2003
01 Nov - 30 Nov 2003
01 Oct - 31 Oct 2003
01 Sep - 30 Sep 2003
01 Aug - 31 Aug 2003
01 Jul - 31 Jul 2003
01 Jun - 30 Jun 2003
01 May - 31 May 2003
01 Apr - 30 Apr 2003
01 Mar - 31 Mar 2003
01 Feb - 28 Feb 2003
01 Jan - 31 Jan 2003

Miscellany

Powered by Pivot - 1.40.0: 'Dreadwind' 
XML: RSS Feed 
XML: Atom Feed 

12 June 05 - 08:15Polymorphism

In every OO class I teach, I introduce encapsulation and polymorphism as the primary OO tactics, with inheritance a distant third. It's hard to tease apart polymorphism and inheritance, because most OO languages are based on an intimate fusion of the two, unnecessarily.

Inheritance is a very strong relationship between objects. It makes it hard to tease anything apart. Some people experience maintenance problems as a result of pervasive inheritance in OO systems. Justifiably, these people then become skeptical about polymorphism as well, because it is so strongly linked to inheritance. They are then tempted to give up on OO altogether. This is throwing the baby out with the bathwater.

My advice as an OO trainer is to use inheritance sparingly, and rely as much as we can on polymorphism.

Polymorphism is an abstraction enabler. The idea is that if we are to describe processes at a relatively high level of abstraction, we are necessarily going to describe in "umbrella" terms a class of situations.

Suppose we are implemeting a Wiki. We might say "One feature of the Wiki is that it logs all edits." Now, "edit" is a nicely abstract term. At a lower level of abstraction, we may well have different kinds of edits: major, minor, spellcheck, file upload, page deletion...

It's a win that we're able to implement the logging feature by writing, in a single place (wherever that is),

for (Edit each in edits)
logStream.append("Edit at "+each.date()+": "+each.debugString())


I have described the type Edit as an "umbrella term"; an abstraction. The type Edit can be an interface in Java terms, or a protocol in Smalltalk terms. No inheritance required, no mutual exclusion implied. One object can perfectly well be an Edit and several other things as well.

What matters is that there are a number of classes of objects which, in a given computation, may play the single role of "Edit". We can say everything we have a need to say about that role in one and only one place. We say nothing about the roles that can played by the very same objects in other computations.

Polymorphism is a well-known phenomenon in molecular biology. A protein folds up for form a "slot" on its 3D surface. Another protein may fit into the first only if it has the proper shape for that slot, called a binding site. Now, more than one protein can have the proper shape to fit into that slot. This mechanism is fundamental to, for instance, vaccination.

In other words, Nature invented polymorphism ages before we rediscovered it in software systems. The designs Nature invents tend to be "smart moves", structures that are so effective that even the undirected, relatively inefficient design process that is evolution will inevitably stumble on them.

Polymorphism is one of these smart moves. Learn how to use it effectively !

- Object Lessons - one comment / No trackbacks - §

09 June 05 - 09:34Organizations and Garbage Collection

Many stable, complex systems produce some sort of garbage - waste material. If allowed to accumulate, waste material interferes with the function of such systems. So systems of this sort tend to have provisions for garbage collection and removal.

I propose that an organization's waste material consists in large part of constraints. Contraints arise from procedures, rules, habits, norms, definitions, titles, etc. These are initially thought up to make things more regular, less chaotic, and therefore easier to arrange in effective ways. With time, and as new rules (etc.) pile up and interact, their effectiveness lapses. Only the rigidity remains.

A colleague of mine wants to install a Wiki for a work group, but he is not allowed to install anything on a server that's not on a corporate list of approved software. There is one thing remotely like a Wiki, that costs a few thousand euros a year, that he was told they'd be glad to install for him if he but asked. Nor can he just install a wiki on a local workstation - that's also locked down by corporate policy.

One sanitation system consists of collective purpose - people decide that there are some results they value more than they value the stale constraints they operate under, and negotiate the constraints away.

(I'd been thinking about this topic for a while, and where does it pop up but on the AYE conference wiki. Kind of spooky - the conference that reads your mind.)

- Management - five comments / No trackbacks - §

Linkdump