Skip to content

Commit b295eb7

Browse files
cynthiaplinss
andauthored
Make naming consistent about methods and arguments. Resolves #195. (#312)
* Make naming consistent about methods and arguments. Resolves #195. Rename functions->methods (where appropriate) and parameters->arguments. * Update index.bs Co-authored-by: Peter Linss <[email protected]> * Update index.bs Co-authored-by: Peter Linss <[email protected]> Co-authored-by: Peter Linss <[email protected]>
1 parent 1c64d38 commit b295eb7

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

index.bs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ the {{CustomElementRegistry/define(name, constructor)|CustomElementRegistry.defi
718718
a <a href="https://tc39.es/ecma262/#sec-static-semantics-constructormethod">Constructor Method</a>.
719719

720720
This takes advantage of the relatively recent addition of classes to JavaScript,
721-
and the fact that function references are very easy to use in JavaScript.
721+
and the fact that method references are very easy to use in JavaScript.
722722
</div>
723723

724724
<div class="note">
@@ -812,7 +812,7 @@ the interaction with garbage collection.
812812
[[!WEBIDL]] attributes should act like simple JavaScript object properties.
813813

814814
In reality, IDL attributes are implemented as accessor properties
815-
with separate getter and setter functions.
815+
with separate getter and setter methods.
816816
To make them act like JavaScript object properties:
817817

818818
* Getters must not have any observable side effects.
@@ -914,14 +914,14 @@ See also:
914914

915915
* [[#attributes-like-data]]
916916

917-
<h3 id="prefer-dict-to-bool">Prefer dictionary parameters over primitive parameters</h3>
917+
<h3 id="prefer-dict-to-bool">Prefer dictionary arguments over primitive arguments</h3>
918918

919-
API methods should generally use dictionary parameters
920-
instead of a series of optional primitive parameters.
919+
API methods should generally use dictionary arguments
920+
instead of a series of optional primitive arguments.
921921

922922
This makes the code that calls the method much more readable.
923923
It also makes the API more extensible in the future,
924-
particularly if multiple parameters with the same type are needed.
924+
particularly if multiple arguments with the same type are needed.
925925

926926
<div class="example">
927927
For example,
@@ -952,7 +952,7 @@ window.scrollBy(50, 0)
952952

953953
</div>
954954

955-
The dictionary itself should be an optional parameter,
955+
The dictionary itself should be an optional argument,
956956
so that if the author is happy with all of the default options,
957957
they can avoid passing an extra argument.
958958

@@ -974,10 +974,10 @@ See also:
974974
* [[#optional-parameters]]
975975
* [[#naming-optional-parameters]]
976976

977-
<h3 id="optional-parameters">Make function parameters optional if possible</h3>
977+
<h3 id="optional-parameters">Make method arguments optional if possible</h3>
978978

979-
If a parameter for an API function has a reasonable default value,
980-
make that parameter optional and specify the default value.
979+
If an argument for an API method has a reasonable default value,
980+
make that argument optional and specify the default value.
981981

982982
<div class="example">
983983
{{EventTarget/addEventListener()}} takes an optional boolean `useCapture` argument.
@@ -989,10 +989,10 @@ Note: Exceptions have been made for legacy interoperability reasons
989989
(such as {{XMLHttpRequest}}),
990990
but this should be considered a design mistake rather than recommended practice.
991991

992-
The API must be designed so that if a parameter is left out,
992+
The API must be designed so that if an argument is left out,
993993
the default value used is the same as
994-
converting {{undefined}} to the type of the parameter.
995-
For example, if a boolean parameter isn't set,
994+
converting {{undefined}} to the type of the argument.
995+
For example, if a boolean argument isn't set,
996996
it must default to false.
997997

998998
When deciding between different list data types for your API,
@@ -1006,13 +1006,13 @@ See also:
10061006

10071007
* [[#prefer-dict-to-bool]]
10081008

1009-
<h3 id="naming-optional-parameters">Naming optional parameters</h3>
1009+
<h3 id="naming-optional-parameters">Naming optional arguments</h3>
10101010

1011-
Name optional parameters to make the default behavior obvious
1011+
Name optional arguments to make the default behavior obvious
10121012
without being named negatively.
10131013

10141014
This applies whether they are provided in a [dictionary](#prefer-dict-to-bool)
1015-
or as [single parameters](#optional-parameters).
1015+
or as [single arguments](#optional-parameters).
10161016

10171017
<div class="example">
10181018
{{EventTarget/addEventListener()}} takes an `options` object
@@ -1127,7 +1127,7 @@ An API should generally be synchronous if the following rules of thumb apply:
11271127

11281128
<h3 id="promises">Design asynchronous APIs using Promises</h3>
11291129

1130-
If an API function needs to be asynchronous, use Promises,
1130+
If an API method needs to be asynchronous, use Promises,
11311131
not callback functions.
11321132

11331133
Using Promises consistently across the Web platform
@@ -1149,7 +1149,7 @@ See also:
11491149

11501150
<h3 id="aborting">Cancel asynchronous APIs/operations using AbortSignal</h3>
11511151

1152-
If an asynchronous function can be cancelled,
1152+
If an asynchronous method can be cancelled,
11531153
allow authors to pass in an {{AbortSignal}} as part of an options dictionary.
11541154

11551155
<div class="example">
@@ -2404,7 +2404,7 @@ Sets of related names should agree with each other in:
24042404
<h4 id="naming-booleans" class="no-num no-toc">Boolean properties vs.
24052405
boolean-returning methods</h5>
24062406

2407-
Boolean properties, options, or API parameters which are asking a question about
2407+
Boolean properties, options, or API arguments which are asking a question about
24082408
their argument *should not* be prefixed with <code>is</code>, while methods
24092409
that serve the same purpose, given that it has no side effects, *should* be
24102410
prefixed with <code>is</code> to be consistent with the rest of the platform.

0 commit comments

Comments
 (0)