Aristotle talked at great length about the essences of things and the accidens of things. The accidens were aspects of appearance that could change (or simply which could be different) while the essences are aspects which one cannot change without fundamentally changing the thing. For example, the accidens of an acorn is a brown seed, but its essence is oak. It could be larger or smaller, and the color could vary, and it could have or not have its cap, but if it were not oak, it could not grow into an oak tree.
Aesop said something fairly similar in the classic fable of the Frog and the Scorpion.
We all know what a frog is, but what is a scorpion? It is a foul little bug with two vicious pinsers and a tail full of venom. They tend to be very foul tempered, and their sting is very painful.
The frogs all know about scorpions. When scorpions would come by the pond or the river, they stung any frog they came across. Every little frog was taught, very young, never to get too close to the mean old scorpions.
One day, a frog was sunning himself by the river when a scorpion came along. The scorpion called out to the frog, “Mr. Frog! Can you take me across the river?” The frog knew that scorpions were mean creatures, so he ignored him. But the scorpion kept asking, ever so politely, “Please, Mr. Frog! I cannot swim, and I need to get across the river.”
Finally, the frog answered, “Sorry, Mr. Scorpion. I’ve been told about how you scorpions sting everyone, and I don’t want to be stung today.” But the scorpion kept begging him, saying, “But Mr. Frog, I told you that I cannot swim. Why would I sting you while you are the only one who can carry me?” Finally, the frog gave in, and the scorpion climbed on his back.
The frog started to swim, and the scorpion rode on his back. Ten feet, and still no sting. Twenty feet, and still no sting. Thirty feet, and still no sting. Halfway across the river, without warning, the scorpion raised his wicked tail and stabbed the frog square in the back. The frog was paralyzed, and they both began to sink.
“But why, Mr. Scorpion, would you sting me?”
And the scorpion replied, as it sank into the river forever, “It is my nature.”
The moral of the story: Never forget that every creature, no matter how it might seem, is a slave to its own nature.
As with so many fables, the story can be applied to many cases, but how would it apply in the world of programming? Well, we know that there are certain programming practices which tend to cause errors and cause trouble for programmers (OOP templates stand out in my mind). When programmers are first exposed to these ideas, they make so much sense and seem so reasonable, but before long the problems start to rear their heads. In order for programmers to avoid being stung, they have to take certain reasonable precautions with their code or use a different technique.
That’s why we think so much about patterns here. There are a bunch of ways to break a program, and a bunch of ways to make your life miserable with code, but patterns are those useful precautions that keep us from being stung, or keep the sting from becoming paralyzing.
Meditate on this little-known fable this week.