I would follow the second thing that btrott suggested. (EDIT I had misread what he wrote slightly and thought I was differing when I wasn't.)

I would have your object contain two other objects, one for input and one for output. The connect method could then be implemented something like this (untested):

sub connect_read { my $self = shift; my $class = shift; $class = "Obj::Driver::$class"; # Load the class if need be then instantiate require $class; $self->{input} = $class->connect_read(@_); }
Similarly for your output method.

For both types of class (input and output) I would define a base class that is worthwhile to inherit from. For instance many of your drivers might need a number of rather low-level functions, but in your object code you may want to talk to a rather high-level functions. Well in your base class put the layer of obvious functions between the simple functions your drivers need to provide and the complex functions you would like to call. Then a driver only need inherit from the base and write a set of low-level functions, and the high-level functions will just work.


In reply to RE (tilly) 1: Object Heirarchy / Design by tilly
in thread Object Heirarchy / Design by lattice

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.