Re: [css-houdini-drafts] [css-typed-om-1] Why is the new thing on ElementCSSInlineStyle called attributeStyleMap, not styleMap

Sorry, but I have to disagree. I can see the reason for wanting to clarify the distinction. However, I think that convenience/brevity is a critical consideration. This goes for naming things in programming APIs just as it does in natural languages:

> One widely known and apparently universal property of human language is that frequent words tend to be short. This law was popularized by Harvard linguist George Kingsley Zipf, ... [who] theorized that this pattern resulted from a pressure for communicative efficiency.

 — "Words in Context: The Effects of Length, Frequency, and Predictability on Brain Responses During Natural Reading" [Cerebral Cortex Vol 26 Issue 10](http://www.pnas.org/content/108/9/3526)

Let's consider how often `el.style` and `getComputedStyle()` are used today. I'd wager the ratio is at least 100:1. I don't know where to find statistics on usage in the wild, but I’m sure Google and others have them.

Extrapolating forward in time, it’s not hard to foresee that `el.attributeStyleMap` will be used much more often than `el.computedStyleMap()`. Let’s name it accordingly.

There are endless analogies; here’s one: When I’m talking about my son Dash with someone who’s met him, I call him "Dash". I don’t use his full name or say "my son Dash". When I’m talking about the robot from Wonder Workshop, I say "Dash the robot". When I’m talking about the character from the movie, I say "Dash from The Incredibles". It’s about frequency.

In APIs, a long name (intentionally or not) sends a signal that something isn’t intended to be used frequently, or that someone (sadly) failed to give adequate consideration to how frequently it would be used. Since jQuery’s heyday, there’s been a trend toward more convenient names in DOM APIs for things we’ll use everyday (e.g. `fetch`, `el.matches`). Let’s not buck it here.

-- 
GitHub Notification of comment by 2is10
Please view or discuss this issue at https://github.com/w3c/css-houdini-drafts/issues/661#issuecomment-377612476 using your GitHub account

Received on Friday, 30 March 2018 20:15:08 UTC