Static vs instance methods on web API pages #248
-
What page(s) did you find the problem on?Include the URL or URLs where you found the problem. Specific page section or heading?“URLSearchParams” What is the problem?Should be What did you expect to see?
Did you test this? If so, how?Nope, I have taken the word of @mathiasbynens (he is probably busy atm, so here is the bug report). |
Beta Was this translation helpful? Give feedback.
Replies: 21 comments 58 replies
-
Writing URLSearchParams.append;
// → undefined
URLSearchParams.prototype.append;
// → ƒ append() { [native code] } To resolve this confusion, I'd suggest using the Note that |
Beta Was this translation helpful? Give feedback.
-
Thanks for this issue. |
Beta Was this translation helpful? Give feedback.
-
@Elchi3 Thanks for the pointer. What's the current status? The discourse thread hasn't received updates in a few years, and it looks like the originally reported issue is still present (except for the ECMAScript language features, which you’ve carefully titled correctly — thank you!). |
Beta Was this translation helpful? Give feedback.
-
Updated the title of this issue. This page may be a good starting point for how we differentiate instance methods and static methods. Perhaps dividing the section into two parts (each w/ separate subheading) would make a clear distinction. [After testing this on Firefox, it appears that none of these methods are static.] Nevertheless, somehow indicating whether static vs. instance methods seems like a good idea. |
Beta Was this translation helpful? Give feedback.
-
I've moved this issue into a discussion as originally the thoughts on moving static vs instance methods happened on discourse ^^ and as we've moved mostly to gh, it'd be good to carry it on here... I was originally going to add highlights from that discussion here, but it's really long - @chrisdavidmills summed it up in this doc here https://docs.google.com/document/d/19ZJbG3tp7CBygsFCj0BeY9CPWCcvnv75GZeTKhGzSlQ/edit#heading=h.kbc6sak698rz Orig discourse https://discourse.mozilla.org/t/incorrect-titles-for-method-property-articles/31641 This is also intrinsically tied into how we represent syntax sections on web api pages. |
Beta Was this translation helpful? Give feedback.
-
I've summed up the previous discussion and Chris' doc: Current formatGenerally Web API pages use the interface name with a capital, then the member e.g. This, by and large, is also used in the syntax section. (See https://developer.mozilla.org/en-US/docs/Web/API/BarcodeDetector/detect ) and for the same reasons can be confusing. Now that static members are becoming more popular within Web API interfaces, we should probably decide on a way to represent this site wide. Options so far:
Other suggestions
ConsiderationsInterface landing pages should be more explicit about instance/static members. I think we've generally started to use the Member pages should state in the summary if they are static: "The static x method of the y interface" Should the JS ref pages be consistent with the decided solution? Another point made in the discourse worth considering is we use the term interface on MDN, which is really class in terms of javascript - I personally don't see an issue with this. We haven't received any communication from developers that this is confusing. Also this term is everywhere and quite a big task to change, for (I believe) not a lot of reward. Syntax sectionsPossibly outside the scope of this title specific discussion, but related. Things I have thought about are the variety within Web APIs:
|
Beta Was this translation helpful? Give feedback.
-
From the user research that was done on this quite a while ago, this was seen as the best option. A lot of interviewees noted that they tend to search for something close to the code they'd actually use to access a property/method |
Beta Was this translation helpful? Give feedback.
-
I quite like some of the 'Other Suggestions' - I don't think users will search for Interface#member... well not until they get used to it maybe. But it's misleading in regards to how you would use the member in code... Possibly one of these two:
It mentions the interface, I like the latter one as we could include 'static method' if it's static. Also it's relatively short compare to a couple of other suggestions. We are still faced with the issue that this isn't how you would write it in code, but I think the colon suggests that you don't. |
Beta Was this translation helpful? Give feedback.
-
Whatever decision is made should be decided on through the lens of best writing practices. The most relevant one are:
A solution like "SharedWorkerGlobalScope: close() method" definitely follows the first. I think the use of a symbol like "#" violates the second. How do I search for the meaning of that? I've never been crazy about having the word 'prototype' in method titles because I don't use that in actual code. But at least you can look it. |
Beta Was this translation helpful? Give feedback.
-
How does everyone feel about this for renaming Web API member pages?
|
Beta Was this translation helpful? Give feedback.
-
@sideshowbarker @Rumyra re https://github.com/mdn/content/discussions/5121#discussioncomment-812580
just a thought. |
Beta Was this translation helpful? Give feedback.
-
One thing I should have commented on the other day is the use of the colon. I don't see what it adds to this. |
Beta Was this translation helpful? Give feedback.
-
I realise this work is yet to start, but I'm might be holding off until web API goes for markdown conversion, just in case I can get this shoe horned in when we tidy up those pages 😬 |
Beta Was this translation helpful? Give feedback.
-
One thing this whole discussion keeps forgetting, it seems to me, is that we're talking about writing not code. There is a best practice that goes "do not take shortcuts at the cost of clarity" (Strunk and White V-19). Specifically, anything that involves a symbol is a shortcut. And if readers have to consult another page to find out what the symbol means, we've failed at the first rule of writing: be clear and direct. (The same applies to the use of prototype in the name.) Why don't we just say what they are? doStuff() Static Method |
Beta Was this translation helpful? Give feedback.
-
whatwg/fetch#1392 raises the priority of this, since there will soon be both |
Beta Was this translation helpful? Give feedback.
-
I made a spreadsheet that I hope summarises the answer in this discussion, showing what page titles would look like for all the different types of reference pages under Web/API: https://docs.google.com/spreadsheets/d/1AqiTcnQa74Dq-pAJKq1LLo3iple2MN1NoWAAGQlorIA/edit#gid=0. |
Beta Was this translation helpful? Give feedback.
-
See also the related issue at at https://github.com/orgs/mdn/discussions/264, which is specifically about what the URLs for the pages should look like. |
Beta Was this translation helpful? Give feedback.
-
One of the consequences of the new Web/API page titles is that they will be longer. It's potentially undesirable to have page titles that wrap - or at least if they are going to wrap we would like them to wrap nicely. Some of our page titles already wrap, and it looks bad: It looks like page titles will start wrapping at around 37 characters (depending on the characters, of course, because they're not in a fixed-width font). In the table below I've summarised how many pages under Web/API (except guide pages, which we might expect to wrap and which are anyway unaffected by the new titles) would be more than 37 characters under the old and new formats.
So this is showing that out of 5695 pages, about a quarter of the new titles will wrap, compared with less than 1/10 of the old ones. However! These long titles will usually contain spaces: ...which actually looks all right. So maybe this is OK? |
Beta Was this translation helpful? Give feedback.
-
A related issue came up yesterday: mdn/content#21960 (comment). The page wanted to link to https://developer.mozilla.org/en-US/docs/Web/API/Navigation/updateCurrentEntry, but the link text was just In this case we can't really have " |
Beta Was this translation helpful? Give feedback.
-
A few weeks ago I filed a draft PR to show what some page titles would look like based in the proposal at https://github.com/orgs/mdn/discussions/248#discussioncomment-3797416. Now people have had a chance to look, this comment summarises where we are with this project and what's next.
So I think if we can agree about the constructor question we can go ahead? If so, the plan is:
This plan does not yet enable us to have separate pages for static and instance methods with the same name. It's necessary but not sufficient, because we also need updated URLs for that. For URLs, I think the plan is to have a |
Beta Was this translation helpful? Give feedback.
-
It's back! See mdn/content#30238 (comment) not to mention https://github.com/orgs/mdn/discussions/248#discussioncomment-4102050 from this thread. We fixed this for page titles but not for in-prose link text. Perhaps we ought to go for We could do this in domxref. |
Beta Was this translation helpful? Give feedback.
How does everyone feel about this for renaming Web API member pages?