Extending
BookSet
to UserBookSet
and
adding in View
s and Validator
s
changes the performance characteristics enormously. If our goal is a
simple, general-purpose class around which to write scripts, it may
not be worth doing. The original BookSet
can add,
edit, and remove transactions quickly as it keeps them in a list, but
most useful queries involve a loop over the entire set of data. A
running UserBookSet
in an interactive application
might have 10,000 transactions in memory, five
View
s open, and two Validator
s.
This means that any addition involves talking to seven other objects,
and an edit involves 14 objects. Naturally, this dramatically slows
bulk operations. However, it dramatically enhances query performance;
a view on the screen displaying month-end balances of every account
might need to redraw only one or two cells of the grid after an edit,
rather than recalculate completely. Think of each running
View
as an extra database index, and you
won’t go far wrong.
No credit card required