"Pluggable" base class architecture

Hi group,
I need an help about designing a pluggable architecture for a library.

This is the idea.
Starting from a Namespace, I need to create a Namespace::Library::Base
class that will be extended by external libraries.

Namespace::LibraryFoo < Namespace::Library::Base
Namespace::LibraryBar < Namespace::Library::Base
[…]

Namespace::Library::Base includes all methods and subclasses needed by
all Namespace::Library* libraries.
But now comes the problem.

Namespace::Library is provided with a set of useful additional classes/
modules, for example

Namespace::Library::XMLParser (module)
Namespace::Library::BaseResultSet (class)
and so on.

Consider the following case

Namespace::LibraryFoo < Namespace::Library::Base

Namespace::LibraryBar < Namespace::Library::Base
and Namespace::LibraryBar::ResultSet <
Namespace::Library::BaseResultSet

Which is, in your opinion, the best way do design this pluggable
architecture.
I was looking at 2 different approaches:

  • mixin (include/extend)
  • include specific libraries when required

What is your opinion?

The two options you mention would seem to be essentially one option,
and it is probably the right one, given the description of the
problem. That is, use include to import specific features into the
derived class. You might give a look to the Ruby Standard Library
Forwardable module as well, which can help you implement delegation in
place of inheritance. Best of luck!

-Dan
http://dev.zeraweb.com/