When I was in second grade Mrs. Hesse tried to teach me basic geometry. The shapes we covered were the trapezoid, the parallelogram, the rectangle, the square, the rhombus, and the triangle. And all of them had their own ways to determine area. A square involved multiplying a side by itself, a rectangle involved multiplying a height by a width —
“But that’s what a square is. It’s just the height is the width,” I said.
Mrs. Hesse was emphatic. Squares and rectangles were different things, and that meant they had to be treated differently. And then we have parallelograms, which are also height times width —
“So they’re rectangles?” I asked scratching my head.
No, they’re different things, and that means they have to be treated differently.
“But we’re not treating them differently.”
Stop being so stubborn, Robert! Now, moving on: a trapezoid—
“That’s a cool word!”
Yes it is. A trapezoid is anything that has a pair of parallel sides. And we compute trapezoids like so:
“That’s awesome!” I exclaimed.
And on to triangles, which are —
“One half the base times the height! Just like a trapezoid!”
No, Robert. It’s okay, this is very confusing, I know. A trapezoid is half the sum of the bases times the height. A triangle is half the base times the height.
“But a triangle is a trapezoid!” I pleaded.
No, Rob. A triangle has three sides and three angles. A trapezoid is a quadrilateral. It has four sides and four angles.
“A triangle is a trapezoid where one of the bases is zero length. One half the sum of the bases, the first base plus zero, is the first base. So it’s half the base times the height!”
Rob, listen, this is very important: different things are different and must be treated differently. A triangle isn’t a trapezoid. I don’t know where you’re getting this.
I sat there in frustrated silence for a moment. “Mrs. Hesse, I know I’m just seven, but — are you sure you understand this stuff?”
I was sent to the principal’s office for my stubbornness.
There are three lessons here for programmers.
First, be careful in strongly-typed languages. Just because two things are of different types does not mean they are actually different in any meaningful way.
Second, be careful in object-oriented design. The hierarchies which make the most sense in formalism (“a triangle is a special case of a trapezoid”) may be completely at odds with the end-user’s expectation of the hierarchy (“triangles are different from quadrilaterals”).
Third, be very careful when you’re telling the person in charge they don’t know what they’re doing. It never goes well, and it goes twice as badly if you can prove you’re right.