Patterns

Here is a short list of patterns. The intent is to document useful patterns for generating mock data, and how to use datamixer to implement them. This section needs more work ...

Collection of Complex Objects

A value list can be populated with complex values. In the next example, the values returned by forEach are added to a value list that is placed in context under the name foo.

    
    <dm:values id="foo">
      <dmf:forEach begin="1" end="5">
	<dm:list>
	  <!-- generate a complex value -->
	</dm:list>
      </dmf:forEach>
    </dm:values>
    
  

The values in the list can be accessed later, perhaps randomly.

Counter

It's often useful to generate all possible combinations of values in several collections. This is an example of the Covariance pattern.

A counter combines values by generating all values from the first iterator. It groups each value with the first value from the other collections. Then it resets the first iterator, generates the second value from the second iterator, and repeats the process again for the first iterator. This continues for all iterators.

For example, the values generated by two iterators over the list ints[0,2] would be (0,0), (0,1), (0,2), (1,0), (1,1), (1,2), (2,0), (2,1), (2,2).

Use a counter iterator to implement this pattern.

Covariance

Suppose we want the values produced by one iterator to be correlated with the values produced by another. This pattern lies at the heart of the relationships among data, and is really a collection of many other patterns (for example, see Counter).

Examples, implementation ... TBD.

I/O Push

An I/O element or attribute that writes values can get them by listening to an iterator. The iterator in effect pushes values at the element or attribute.

Use this pattern when ... TBD.

I/O Pull

An I/O element or attribute that writes values can get them by calling getNextValue() on an iterator. The element or attribute in effect pulls values from the iterator.

Use this pattern when ... TBD.

Random Values

Values can be selected randomly from a collection with a RandomIterator . If values are selected without replacement, then all values must be selected from the collection before a value is reselected. This operation is expensive in memory, as an array that contains the indexes of all values is created, to ensure no value is selected twice.

A uniformly distributed, double precision value between 0.0 and 1.0 can be generated with RandomFunction .