Archive for the ‘wrapping’ Category

h1

Striped Wrapping

November 2, 2015

original_stripe-wrapping-paper
Wrapping can be thought of  adding a filter to the input of a procedure, and also the output.

The easy case is when the procedure is the outermost layer.

The problem of striped wrapping is how you do that to a procedure which is at in intermediate level of an already built  programme.

That is itself a part of the problem of plugins: how do you 1) add a component, that 2) effects every aspect of an existing system, without 3) rewriting the existing system.
Standard modules are supposed to implement only one aspect of a system, so plugins are a cross-cutting concern in relation to them. Complex systems have aspects, such as data storage and user interface, and and they also have features, such as billing and user authorisation. Features can potentially involve all aspects. Plugins are intended to implement features in a swappable way. (I call this two dimensionalism).

Class based object-orientation presents a bad way of freely adding features. If Class C inherits from class B which inherits from class A, you can’t interpolate — stripe — some 4th class in the chain without changing the existing code.

The currently fashionable technique of dependency injection is much better: major changes can be made by modifying the highest level of code alone. In a sense the top level of code is a kind of configuration.

Dependency injection is a variation on the call back mechanism. Another common (but contrasting) pattern for extending existing code without modifying it is the wrapper. Cleanly implemented wrappers require their own syntactic form.