Congratulations Discipulus!

Without seeing an overview of all the various pieces, it's hard to come up with the best scenario here, so anything I say here is just off the top of my head.

In Win32::Event2Log, you could use the Engine as a base class, and in the Engine, you could use (or optionally require at runtime depending on the user's selection). Then, for example, if a user wants a specific "type" (ie. Reader, or wrapper for the binary):

my $obj = Win32::Event2Log->new(engine => 'type');

Then, in the constructor above:

use 'base' Win32::Event2Log::Engine; sub new { my ($class, %args) = @_; my $self = bless {%args}, $class; # select_engine inherited return $self->select_engine($self->{engine}); }

In Engine

use Win32::Event2Log::Reader; use Win32::Event2Log::Wevtutil; sub select_engine { shift; # throw away Event2Log object, unless needed/wanted my ($engine) = @_; my %engines = ( reader => sub { return Win32::Event2Log::Reader->new(...); }, wrapper => sub { return Win32::Event2Log::Wevtutil->new(...); +}, ); $engines{$engine}->(); }

Very much untested, and again, I'm a bit confused as to how the whole thing ties together, so this is just one example of what can be done here. If you add more functionality in the future, you'd just need to modify Engine, as the Event2Log module simply passes the "type" along as an argument. Engine can take care of managing the actual engines, as it probably should.


In reply to Re: subclassing: how to design my module by stevieb
in thread subclassing: how to design my module by Discipulus

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.