The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

hubuse - Using the Hub library

SYNOPSIS

The Hub module represents functions and classes which are implemented in descendant packages. Hub dynamically loads modules according to the parameters it is used with.

DESCRIPTION

Don't use the underlying modules directly:

  use Hub::Base::Logger;        # Wrong
  use Hub;                      # Correct

  my $logger = Hub::Base::Logger->new( 'my.log' );    # Wrong
  my $logger = Hub::mkinst( 'Logger', 'my.log' );     # Correct

Without getting into gory detail, this non-standard approach is in place for two reasons:

  1) Allow the library to be refactored (maintained) without impacting existing
     code.

  2) We don't want to short-circut Perl's built-in require functionality which
     would be necessary.

Module Directory Structure

By default, Hub tries to be as efficient as possible, only loading packages which are necessary. Descendant packages are BulkSplit so that when it is required, only the header (dependancies and export lists) are loaded, and the body is AutoLoaded on the first call to a subroutine. See hubsplit for details.

Subdirectories are used to group exported modules. Underneath the root (Hub) directory, are sub-directories which represent the export tag of which the underlying modules should be represented.

    Hub/:
      |-Base/:
      |-Util/:
      `-Webapp/:

Descendant packages maintain their exported symbols in the EXPORT_OK array. The Hub module proxies these exported symbols, thus requiring all descendant- exported symbols to be unique.

Classes are created with the Hub::mkinst using their short-name. Thus requiring them to be unique (to other classes):

  1. Hub::Custom::Class.pm       # defines function 'new'
  2. Hub::Another::Class.pm      # doesn't define 'new'
  3. Hub::Yetagain::Class.pm     # also defines 'new'

#1 and #3 will clash because they are both classes, but either can be used with #2 simultaneously.

AUTHOR

Ryan Gies

COPYRIGHT

Copyright (c) 2006 Livesite Networks, LLC. All rights reserved.

Copyright (c) 2000-2005 Ryan Gies. All rights reserved.

UPDATED

This file created by mkdocs.pl on 8/29/2006 at 2:07pm