"Pluggable" base class architecture

S

Simone Carletti

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

1.
Namespace::LibraryFoo < Namespace::Library::Base

2.
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?
 
D

Dan Yoder

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/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top