Changes between Initial Version and Version 1 of Ticket #16599, comment 16


Ignore:
Timestamp:
Jan 24, 2013, 4:29:38 PM (9 years ago)
Author:
Brian Arnold
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #16599, comment 16

    initial v1  
    55I really hope that doesn't sound like a jerk thing to say, but the need for a data structure that's truly hierarchical and not flattened is fairly uncommon, and queries against flattened structures are inherently deep. If a user doesn't want a deep query in that context, it's easy enough to query for items with a specific parent key (or lack thereof).
    66
    7 The main problem with hierarchical data of this nature is that in order for a simple `get` to work, you'd still have to do a full traversal of the data in order to index all items by identifier, and this traversal would ideally happen at initialization. If your data is flat, you simply loop. If it's not, you have to recurse -- but you still wind up generating a flat representation of the data in the ideal case to simplify querying, and that starts to approach the weight and proscriptive data structures that dojo/data requires.
     7The main problem with hierarchical data of this nature is that in order for a simple `get` to work, you'd still have to do a full traversal of the data in order to index all items by identifier, and this traversal would ideally happen at initialization. If your data is flat, you simply loop. If it's not, you have to recurse -- but you still wind up generating a flat representation of the data in the ideal case to simplify querying, and that starts to approach the weight (both LOC and memory) and proscriptive data structures that dojo/data requires.
    88
    99I would go so far as to argue that representating your data with deeper hierarchical structures is an antipattern, that doing a flattening is going to save time and effort for both the developer of the store and the user of the store. A reference store that demonstrates that approach would not be immensely difficult, but hierarchical data structures are distinct enough that it'd be difficult to create a generalized implementation. Parent-based keying is incredibly common and simple to implement in a general fashion without being proscriptive.