Selector Diagram

What Select members of a collection that have specified properties.

When Selection is a universal in interactive systems. In parametric systems, selection can be part of the model itself. At each update of the propagation graph, objects can select the arguments to their update methods. Use this pattern when you want to locally and dynamically restructure a model depending its state.

Why Creating objects and using objects are different acts. You will often specify, say, a set of points by giving their Cartesian coordinates. When it comes to using these points, you might be interested only in those that are close to a line. The selector pattern allows you to separate object creation and later use, and express these two common operations in the terms most suitable for each.

How In the Selector pattern, there is always a collection of given objects and a collection that is the outcome of the Selector's action. We call the first list the target and the second list the result. The Selector object mediates between these by determining which elements of the target to include in the result. The properties that objects must have or conditions they must meet in order to be selected we call the Selector's behavior.

For example (See the Sample entitled Distance of Points), the target may be a list of points and the Selector a compound of a point, a circle and a function. The point provides the location of the Selector; the circle displays the distance within which selection will occur; and the function specifies how points will be selected and how selected points will be constructed. The function embodies the Selector's behaviour. The aim is to select the points whose distance to the Selector point is less than (or greater than or equal to) the variable d which itself parameterizes the Selector's behaviour.