JMU
Conformal Arrays
A Programming Pattern


Prof. David Bernstein
James Madison University

Computer Science Department
bernstdh@jmu.edu


Motivation
Review
Thinking About the Problem
The Pattern

Choose the form that satisfies the following criteria:

Records and Fields

A Visualization

images/ConformalArrays.svg
The Economics Example

Month CPI Unemp. M2 Confidence
Jan 247.867 4.5 13855.1 Low
Feb 248.991 4.4 13841.2 Low
Mar 249.554 4.1 14022.9 Moderate
Apr 250.546 3.7 14064.4 High
May 251.588 3.6 13984.6 High
Jun 251.989 4.2 14079.2 Moderate
Jul 252.006 4.1 14113.8 Low
Aug 252.146 3.9 14170.3 Moderate
Sep 252.439 3.6 14204.7 Moderate
Oct 252.885 3.5 14211.6 High
Nov 252.038 3.5 14272.8 High
Dec 251.233 3.7 14473.0 High

The Economics Example (cont.)
The Economics Example (cont.)

The Conformal Arrays

javaexamples/programmingpatterns/conformalarrays/ConformalArrays.java (Fragment: economicdata)
                // Month of the year
        String[] month = {
            "Jan", "Feb", "Mar", "Apr", "May", "Jun",
            "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };

        // Consumer price index for all urban consumers
        // (not seasonally adjusted)
        double[] cpiaucns = {
          247.867, 248.991, 249.554, 250.546, 251.588, 251.989, 
          252.006, 252.146, 252.439, 252.885, 252.038, 251.233 };

        // Unemployment rate (not seasonally adjusted)
        double[] unratensa = {
            4.5, 4.4, 4.1, 3.7, 3.6, 4.2, 
            4.1, 3.9, 3.6, 3.5, 3.5, 3.7 };

        // M2 money stock (not seasonally adjusted)
        double[] m2ns = {
            13855.1, 13841.2, 14022.9, 14064.4, 13984.6, 14079.2, 
            14113.8, 14170.3, 14204.7, 14211.6, 14272.8, 14473.0 };

        // Consumer confidence
        String[] confidence = {
            "Low", "Low",      "Moderate", "High", "High", "Moderate",
            "Low", "Moderate", "Moderate", "High", "High", "High" };