Extensibility Pattern - Configuration Files As Extensions

Configuration Files As Extensions

A ConfigFile may be enough to customize the module for reasonable needs. It may also specify modules by name to be created and employed in a framework.

# the config.pl file defines @listeners to contain a list of class names # that should receive notices from an EventListener broadcaster, # referenced by $broadcaster. require 'config.pl'; foreach my $listener (@listeners) { require $listener; my $list_inst = $listener->new; $broadcaster->add_listener($list_inst); }

See Event listener for the broadcaster/listener idiom. This avoids building the names of listener modules into the application. An independent author could write a plugin to this application: she would need only have the user modify //config.pl// to include mention of the plugin. Of course, modification of //config.pl// could be automated. The install program for the plugin would need to ask the user where the //config.pl// is, and use the ConfigFile idiom to update it.

Read more about this topic:  Extensibility Pattern

Famous quotes containing the words files and/or extensions:

    The good husband finds method as efficient in the packing of fire-wood in a shed, or in the harvesting of fruits in the cellar, as in Peninsular campaigns or the files of the Department of State.
    Ralph Waldo Emerson (1803–1882)

    If we focus exclusively on teaching our children to read, write, spell, and count in their first years of life, we turn our homes into extensions of school and turn bringing up a child into an exercise in curriculum development. We should be parents first and teachers of academic skills second.
    Neil Kurshan (20th century)