The WyCash Report Writer

OOPSLA-91 Workshop 9
Towards an Architecture Handbook

Ward Cunningham
Wyatt Software

Pension funds, corporations, and banks invest billions of dollars in the "cash" markets. Incredibly diverse in nature, cash securities are actually negotiated between issuer and buyer, and new security types are frequently introduced into the market. WyCash is a portfolio management system which provides basic accounting, record-keeping and reporting, as well as analytical computations to assist the manager of cash portfolios.

Most of the almost one thousand classes in WyCash are specific to the field of portfolio management. There are, however, numerous examples of small collections of classes that are both general and of utility far greater than their small size might suggest. This paper outlines one such example, the WyCash report writer. Although report writing is rarely considered an interesting subject, we have several reasons to believe the classes involved may be of lasting interest. They are useful. We would not consider working outside of their framework. They are flexible. We routinely escalate the requirements for this section of the program and have yet to retract a major design decision. Finally, they are valuable. Customers often cite the report writer as a reason to buy our product.

We attribute the report writer's success to a careful division of responsibility between the four major components (class hierarchy fragments) listed below.

Report
Query and update application data.
Tabulate results.

ReportBrowser
Present a Report in a window.
Detect and refresh stale data.
Create new Reports.

Row
Represent a unit of domain-specific information.

Column
Access and Format information in Rows.
Aggregate information across Rows.

Both Rows and Columns perform calculations. Within a row a calculation is given a name and implemented as a method indistinguishable from any other domain method. Within a column information travels down a column appearing in totals and subtotals along the way. Columns are factored into a hierarchy based on the nature of the of the computation they perform. One of the more surprising discoveries is that the number of different computations required is small (seven) and stable (unchanged in any version). The responsibilities for each kind of column are listed below. The column hierarchy is shown in figure 1.

Column
Access and update values in (or computed by) rows.
Recover from errors in value computations.
Convert values to and from formatted (string) representations.

CachedColumn
Cache retrieved values to avoid redundant computation.

AccumulatedColumn
Convert values by summing with prior rows (arithmetic sum).

CompoundedColumn (a kind of AccumulatedColumn)
Convert values by compounding with prior rows (geometric sum).

TotaledColumn
Report totals for spans of rows.

AvreragedColumn (a kind of TotaledColumn)
Report weighted averages for spans of rows.

ProportionedColumn (a kind of TotaledColumn)
Convert values to percent of total.

The column hierarchy has proven useful for factoring computations that would otherwise be repetitious with formatting, missing value logic, error handling and the like. Consider the computation of percent-of-portfolio for a position report. (See figure2.) The calculation is to find what part each row (a position) contributes to the whole (all positions in the portfolio). We employ a ProportionedColumn configured to examine the market value of each row. It inherits both formatted (at:) and unformatted (valueAt:) accessing methods, the latter of which it overrides to insert its calculation. The calculation has available the row's market value (super valueAt:) and the total market value (total inherited fromTotaledColumn) and simply divides (with checks) one by the other.

This paper has focused on the most distinctive features of the objects in WyCash that have come to be called its report writer. In particular, the choice to model Rows and Columns (as opposed to, say, Arrays of Cells) created the opportunity for a well developed Column hierarchy. It is an important architectural distinction that has had a profound and positive impact on the organization of WyCash.


ward@c2.com