Mixins and command suites

The Compound Document framework uses the concept of mixins to save developers having to continually rewrite code to accommodate interface changes.

A mixin class defines a given interface to an unspecified set of selections. When you want to permit a selection to be acted upon by a suite of commands, you simply add the mixin class to the classes from which the selection inherits.

Command suites are written to use the mixin class rather than apply to a specific selection type. Thus you can write commands that can be applied later to a new selection type without having to worry about the design of the selection type.

When you add a new selection type, it too uses the interface defined by the mixin class (by using multiple inheritance to inherit from the mixin class as well as any other classes):


When you need to add a new suite of commands, make sure that they can operate on the interface defined by the mixin class. If they can, then they can operate on any selections that inherit from that mixin class.

One example might be a set of commands that manipulate the color of selected objects. Such a command suite could provide a selection mixin MColorizable. Selections inheriting from this mixin class could immediately have their data colored by the newly available commands.


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker