Scripted Components

Problem

How can one decompose an application into reusable components that can
easily be adapted for different uses, possibly at run time or by
inexperienced programmers?

Context

A useful software component is one that is relatively context free, making few
assumptions about other software components it interacts with. Such components
are readily reusable. Programmers can treat them as "black-boxes", instantiating
and using them without having to modify, extend or even understand their
implementation. Designing systems as being made up of black-box components
is a useful discipline because such systems are easy to understand and their
their constituent components are easy to reuse.

Forces

Components must be loosely coupled: they must rely on as few other components
as possible.

Components must be reusable: it must be possible to use them in as many
situations involving as many other types of component as possible.

Components must be composed into applications at run-time.

Components must be useable by people for whom programming is not their
primary skill or function.

Solution

Use a language interpreter as a
Mediator between reusable
components.
For each component type, implement interpreted commands to instantiate
the component and control its operation.
The application instantiates a language interpreter and initialises
itself by executing a program in the interpreted language.
The interpreted program encapsulates the application-specific
configuration of components and controls their interactions.

Consequences

Components are highly modular, being fully decoupled from all other components
but the language interpreter itself.

It is easier to compose components into a complete application using a
scripting language than it is to use a full-featured systems programming
language because scripting languages are much simpler. Scripting
languages can therefore be used by inexperienced programmers or people
for whom programming is not their primary occupation, while the components
they use can be implemented by experienced software engineers.

The component implementor must define the interface between the script
interpreter and the component. This is usually performed by implementing
a procedure that accepts a statement in the scripting language as one of
its parameters and interprets the statement in some component-specific
manner.

Components can be interconnected using Glue
Code.
If this is a performance problem, the binary interfaces of components
can be connected directly using
Configuration Scripting.
One-to-many and many-to-many relationships between components can be
implemented with Broadcasters.

Known Uses

Scripted Components are used in many development
environments, incuding: