I use inheritance quite a lot in real projects. One particular example in the old days was a framework for serialization/deserialization of objects in XML. This was implemented in both Perl and Java so that Perl objects could be serialized and deserialized as Java objects and vice versa. In both Perl and Java classes that implement this were subclasses of the 'GObject' class that had all the necessary logic.

Another example: a library for finite state machines that also implements a finite state transducer. The latter adds functionality to the former, so it inherits all from the finite state automaton, but adds code to actually output things rather than just accepting or rejecting.

Another example was a Perl wrapper around a C library that implemented connectivity to custom servers. All servers shared some functionality, but differed in the kind of requests one could do and the data they returned. Hence I had a base class implementing basic connectivity while the classes that inherited from it implemented the specific functionality.

Oh well, very useful concept... just my 2 cents, -gjb-


In reply to Re: Real live usage of inheritance? by gjb
in thread Real live usage of inheritance? by BUU

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.