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.
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.
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.