in reply to Re: Perl 6 shocking revelations #1
in thread Perl 6 shocking revelations #1

When oh when will someone come up with inheritance examples that aren't based on geometry or phylogenetics.

About twenty years ago I worked on a system written in C++ that dealt with various financial instruments (fixed term deposits (with fixed or variable interest rates), stocks, bonds, options, futures and all that financial soup). The original architects had decomposed the different instruments into distinct classes (class Bond, class Option and so on).

Sadly, they completely missed the concept of ISA hierarchies. A lot of these instruments build on existing things, with an added twist. Yet the architects had merely cut'n'pasted code from class to another, for things like yield and amortisation calculations. Which meant that you had to chase down similar bugs in many similar classes.

Having learnt object-oriented programming a few years previously with such toy examples as decried by BrowserUK, it struck me that here was a real world example that was easy to explain, easy to code, produced tangible results and probably one of the few textbook cases where true inheritance hierarchies really make sense (insofar as compositional has-a architectures are much more frequent).

Fortunately enough for me, I left the project and moved on to greener pastures, and since then I have managed to forget just about everything I had learnt about the subject, but someone who has kept up with the field should be able to produce a simple example to demonstrate the basic concepts.

• another intruder with the mooring in the heart of the Perl