[Dev] Small tweak to parcel loader
Morgen Sagen
morgen at osafoundation.org
Fri Jun 11 10:49:33 PDT 2004
I wan't closely involved in the development of
defaultValue/initialValue, but this is my understanding (and those in
the know should correct me):
In the beginning there was defaultValue. As folks used it, and
discovered that defaultValues didn't participate in queries (and for
perhaps other reasons, such as defaultValue collections are read-only),
it was decided to implement initialValue. I believe there was
agreement that the apps group would be standardizing on initialValue.
Recently there has been some talk about the possible inefficiency of
using initialValue (since you could potentially have lots of copies of
the same value), and therefore there are some cases where defaultValue
might make sense (since there is one shared copy of the value, attached
to the attribute itself and not to each item).
A question I have for Andi is: "what is more efficient (in terms of
time): looking up the value of an attribute that has been given an
initialValue, or a defaultValue?" Potentially, retrieving a
defaultValue means there's an extra place to go look for a value (but I
haven't checked the code yet to see how this works).
If one is more time-efficient than the other, then we have to decide
whether we want to optimize for look-up time rather than memory
footprint. It would be interesting to see what real-world performance
gains/costs there are in using either method. Without having that
data, my inclination would be to standardize on initialValue because
it's easier to explain to people, and it offers the behavior that I
expect. However, if you understand the differences between the two and
you feel you want what defaultValue provides, then I guess you're free
to use it. It's nice to give the developer the choice, since they know
the characteristics of their items; for example, if you have 100,000
items and only a handful are going to have a non-default value for one
of their attributes, it might make sense to choose defaultValue over
initialValue in order to reduce memory footprint.
Again, since the decision about which you choose is based on
hypothetical performance differences, it would be nice to actually know
what real-world benefits there are (time-wise and memory-wise). I'm
willing to do some tests if that would help this discussion, or perhaps
others have already looked at this.
~morgen
P.S. So Lisa, the answer to your question is, "it depends". :-) I
would say use initialValue unless you have a reason not to.
P.P.S. For those who don't know the difference between defaultValue
and initialValue, Andi has it documented here:
http://www.osafoundation.org/docs/current/api/
repository.item.Item.Item-class.html#getAttributeAspect
On Jun 11, 2004, at 9:51 AM, Lisa Dusseault wrote:
> So for example "attendees" of an event ought to initialize to an empty
> list? or default to an empty list?
>
> thx,
> Lisa
>
> On Jun 11, 2004, at 9:25 AM, Morgen Sagen wrote:
>
>> By popular demand: if you want to set the defaultValue or
>> initialValue of a list or dict attribute to be an empty list or dict,
>> you may now include either "<defaultValue/>" or "<initialValue/>"
>> inside that attribute's definition. For example:
>>
>> <Attribute itemName="listAttr">
>> <displayName>List Attribute</displayName>
>> <cardinality>list</cardinality>
>> <type itemref="String"/>
>> <initialValue/>
>> </Attribute>
>>
>> ~morgen
>>
>> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>>
>> Open Source Applications Foundation "Dev" mailing list
>> http://lists.osafoundation.org/mailman/listinfo/dev
>
More information about the Dev
mailing list