durusmail: durus-users: ComputedAttribute example
ComputedAttribute example
2009-12-31
2010-01-27
ComputedAttribute example
Binger David
2010-01-27
On Dec 31, 2009, at 12:51 AM, Andrew Moffat wrote:

> Hi,
>
> I'm having trouble wrapping my mind around the ComputedAttribute class.  I
can't figure out a use case, mostly because I can't seem to understand what it
actually does.  Would someone be so kind as to provide me with a short code
example and explanation?

If you have, for example, a large collection of Stars, and you need to have
quick access to
some statistic, such as the average brightness, of your Stars, you might choose
to implement
this using a Computed Attribute.  In this case, the value of the computed
attribute is derived entirely from
other information that you already have in your database, and maintaining it as
a separate persistent
object would just open the door for error.  The ComputedAttribute is essentially
a cached value that
can be invalidated when, for example, a Star's brightness is changed.
The tricky part of this business is when the durus server has multiple clients,
potentially
holding different cached values of the computed statistic.

ComputedAttribute works fine, but over the years we've gradually eliminated
these
from our actual working databases.  There is usually a way around it that gets
the job done.

>
> By the way, I'm loving Durus.  I'm a long time SQL user here, and I've taken
to object serialization surprisingly well.  I had my doubts, but they've all
been resolved.  Thanks for such a great project.

We really like it too, and we're glad that you do.

reply