Re: sort attribute for referenced relation

From: Holger Hoffstätte (holge..izards.de)
Date: Tue Dec 03 2002 - 19:42:38 EST

  • Next message: Holger Hoffstätte: "Re: sort attribute for referenced relation"

    Andrus wrote:

    [snip]

    > Now, Java has a notion of "unmodifiable" lists (via java.util.Collections
    > wrappers), though this is dumb and not obvious from the interface. So we
    > can take advantage of that and make sure that relationship list is
    > "unmodifiable", and safely implement the sorting.

    Like Dirk alread said in the follow-up, the UnmodifyableCollection is a
    joke and useless in reality.

    > logic, a user should be in full control of the list. So once she
    > inserts/removes something, she shouldn't expect it to be ordered (since she
    > just modified it). Instead she could use Collections API to order it any
    > way she wants.

    But we can do better! :)
    Of course fetching already sorted rows from the DB is a great start but
    having no support on the object side of things is IMHO not good enough,
    since you will then reintroduce duplicate ordering logic, but
    inconsistently since it is likely not needed everywhere. In EOF I have
    never inserted a new EO into a relationship at a specific index; I
    _always_ used either addToFoos or sparingly addObjectsToBothSides(). Of
    ocurse this was mandated by the API (NSMutableArray exposed as NSArray)
    but since we cannot do this in Cayenne (List is unfortunately always
    mutable) at least basic support for automatic ordering should be there.

    The simplest way would be to create List accessor for unordered
    relationships (like it is right now), and for ordered relationships the
    OrderedList interface can be used (see other mail). Since it's a
    subinterface of List, other classes working with List will still work
    gracefully. I think if Collections helper class and Iterator/ListIterator
    work, anything else will work as well.

    -h



    This archive was generated by hypermail 2.0.0 : Tue Dec 03 2002 - 23:07:52 EST