# "Pluggable" base class architecture

**URL:** <https://www.ruby-forum.com/t/pluggable-base-class-architecture/117917>\
**Category:** Ruby\
**Created:** [October 22, 2007, 1:02pm UTC](https://www.ruby-forum.com/t/pluggable-base-class-architecture/117917 "2007-10-22T13:02:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![overclokkato](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/c67d28/32.png) [@overclokkato](https://www.ruby-forum.com/u/overclokkato)\
**Post date:** [October 22, 2007, 1:02pm UTC](https://www.ruby-forum.com/t/pluggable-base-class-architecture/117917/1 "2007-10-22T13:02:13Z")

</div>

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

1. 

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?

---

<div class="post-metadata">

**Author:** ![overclokkato](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/c67d28/32.png) [@overclokkato](https://www.ruby-forum.com/u/overclokkato)\
**Post date:** [October 28, 2007, 9:25pm UTC](https://www.ruby-forum.com/t/pluggable-base-class-architecture/117917/2 "2007-10-28T21:25:57Z")

</div>

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/](http://dev.zeraweb.com/)
