ES accessor usage guidelines (Was: Map/Set.prototype.size)

Tab Atkins Jr. jackalmage at
Tue Oct 16 16:16:35 PDT 2012

On Tue, Oct 16, 2012 at 4:06 PM, Yehuda Katz <wycats at> wrote:
> On Tue, Oct 16, 2012 at 6:26 PM, Mark S. Miller <erights at> wrote:
>> Getting the comments with a getter seems fine. Appending only the list of
>> comments with a setter is bad, as it does not resemble storage semantics.
> Do you mean appending only to to list of comments?
> ` = post` has similar semantics to setting a foreign key in a
> SQL database, which will (obviously) update future requests for "all
> comments with". Bidirectionally linked one-to-many
> relationships are pretty common, and it's desirable for the relationships to
> remain in sync automatically. I don't think this is the right heuristic for
> moving to a method.

Yup; as I argued, the setter only has "non-local" effects if you're
using denormalized data (which you almost certainly will be, because
it makes the more-common reads more efficient).  It's definitely
possible to implement identical behavior by having the setter only
have a local effect, and having the getter be an expensive traversal.


More information about the es-discuss mailing list