Possibly something like:
@ISA = qw(Display::Base);
@ISA = qw(Display::DBI);
If you're wondering if the language will enforce anything OOP ... the short answer is "No". It enables OOP, but doesn't enforce it like C++, Java, and/or Smalltalk. Perl isn't an inherently OOP language.
The plug-in architecture you're describing is essentially an overloaded base class. A few caveats:
- If you feel the need to do a if ($display->isa('Display::LDAP')) in your client code, think long and hard. The point behind plug-ins is that you don't know which it is.
- Write your plug-in objects so that they ignore any data they don't need. This allows you to have data that some plug-ins might use, but not others. The client would create all data for any object anyways.
This is best facilitated by passing hashrefs or objects around. Don't use fixed-size param lists.
- You seem to have done this, but I'll say it anyways. Come at the design from the perspective of what you would need to display to ANY of the formats, then create your object(s) or hashref to pass to the displayer accordingly.
Don't start with one or two, then try and extend. You'll end up with some nasty Anti-Patterns.
Most importantly, if you come up with a really neat implementation, post it to CPAN.
We are the carpenters and bricklayers of the Information Age.
Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.