I was reading through Ed Yourdon's "Decline and Fall of the American Programmer" the other day. In Chapter 5, section 5.8.6 page 127 to be precise, he is comparing the differences between practitioners of Structured Analysis (SA) and Object-Oriented Analysis / Design (OOA/D). In commenting on how OOA/D values reuse more than SA does Yourdon trots out the standard inheritance example of Vehicle (parent) / Automobile (child). It hit me that this example of inheritance is actually a very BAD example. However innocent this example may seem, it can sew a false sense of security in a programmer.
Summary
1) Inheritance is a complex topic
2) Using a simple example to introduce a complex topic is admirable
3) Using an incorrect example creates students who, among other possibilities, try to extend the example and become confused or have a false sense of their understanding of the subject.
4) Using a bad example in class materials is inexcusable for a teacher who claims they understand the subject and who care about what the students get out of the class.
I tried to explain my reasoning to Craig and here is how the discussion went.
Note: Link to the definitions used by the FAA to distinguish aircraft types.
Kelly
The things which we like to use to show inheritance are really capabilities of vehicles in general
I created a list of categories like so:
Craig
I'm still not sold on the idea that an automobile, train, boat, etc breakdown is a bad classification
Kelly
Vehicle; land, water, air; wheeled, hulled, tracked, winged, floats; motorized;
A car is wheeled and motorized for land
a boat is motorized and floats
If you try to put 'wheeled' in the hierarchy it gets strange when you want to declare a plane
It is motorized, has wings but can also have wheels.
You can't attach 'wheeled' to a pre-ordained location in the hierarchy
Knowing a vehcile has wheels does nothing to tell you where it belongs in the hierarchy.
An amphibious landing craft, an airliner, and a car all have wheels and they have motors.
All those things are actually attributes of some category at a higher level
A car is shorthand for a collection of attributes: piloted, wheeled, motorized, land vehicle
If you use those terms to define your hierarchy, you get problems when you introduce vehicles with different combinations of capabilities.
A Barge is unpiloted, floats, unmotorized, but is still a boat
A hot-air balloon is piloted but has no wheels or motor but is still an aircraft
Craig
hmmmm. I need to ponder more
Kelly
food for thought, at least?
Craig
yes. a mid afternoon snack
I think your approach is a valid approach to deconstructing the hierarchy, but I don't think the use of "automobile, boat, etc" is wrong.
Kelly
using them as labels is fine
but it becomes hard to use them in a OOP hierarchy without being about to define exactly where they belong and the differences between them.
There are much better subject areas to use, like the animal kingdom
where you can easily say "All live-bearing animals are mammals"
Unless a teacher knows how to categorized vehicles as clearly, they should avoid using it as an example
I believe that the FAA defines a plane as a fixed-wing aircraft. Helicopters are aircraft but aren't fixed-wing while hot-air balloons are aircraft with no wings at all.
In other words, 'Plane' is an instance of a class of vehicle called 'fixed-wing aircraft'
Craig
While cars are four wheeled passenger automobiles and big rigs are eighteen wheeled cargo automobiles, perhaps
Kelly
I got that wrong.
A 737 is an instance of a class of vehicle called 'fixed-wing aircraft'
which we call, a plane.
you do have the right idea
Craig
So you're saying automobile is too generic of a word.
Kelly
A 'plane' is not a type
Craig
I can accept that
Kelly
right
it lulls the student into thinking they understand the is-a relationship
Using planes might be better because the FAA has to use precise definitions or else their regulations would make no sense.
Kelly
is my rant making more sense now?
Craig
yes
The FAA definitions as an example helped
It gave me something to compare against
Kelly
Yes, they define legal regulations for things like 'right of way' based upon the maneuverability of an aircraft.
rotary-winged craft gives way to a fixed-wing craft gives way to a hot air balloon
Craig
I kept thinking the actual classification of vehicles as certain types can't be wrong, but the fact that the general classifications we use in classroom examples as too generic is an insightful observation
Kelly
for the simple fact that the maneuverability goes down
Have you seen the email where an aircraft carrier is in radio communication with someone else
and the carrier is insisting that the other party get out of the way?
and it turns out that the other party was in a lighthouse.
Craig
ROFL
Kelly
Distinctions are important.
When we teach about inheritance we're smack in the territory where distinctions are critical.
When we use the 'vehicle/automobile' example we fail to enforce with lax distinctions
Wednesday, January 14, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
I reserve the right to delete inappropriate comments at my discretion