Class design issues - members keep on growing
The application is a financial modeling system where objects of a class
are generated as time goes by, for different timeframes (hourly, daily,
weekly, and even down to minutes) so the number of object instances are
massive. The problem is, as the system progresses in its modeling stage,
objects are filtered in multiple stages, and more and more 'information'
are computed (via filtering) and need to be recorded in the objects. the
simplest approach is to treat them all as a uniform class, but the
downside is almost 90% of the objects are filtered out without the need to
carry those 'extra information/data members', causing tremendous memory
waste. These objects, even filtered out, are needed for statistical
purpose, thus can not be free.
One possible solution is to define derived classes for the filtered one to
accommodate the extra data members. This implies during the
filter/selection process, results are new instances of the derived class
and the original contents are copied to the new instance. The problem with
this approach is a LOT of object comparison operations will need to be
changed to 'deep comparison' by comparing all members, rather than the
original reference comparison. I would imagine the performance hit will be
non-trivial.
Any suggestion how to solve this nasty problem?
No comments:
Post a Comment