File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -48,7 +48,15 @@ foreign name should be prefixed for disambiguation, or even both.
4848
4949### The name should describe the content
5050
51- - An array of ` thing ` should be called just ` things ` .
51+ - An array should have a name that gives clues about its content.
52+ ``` javascript
53+ // Bad.
54+ const things = [' dog' , ' cat' , ' mouse' ];
55+
56+ // Good.
57+ const animals = [' dog' , ' cat' , ' mouse' ];
58+ ```
59+
5260- An object of ` thing ` indexed by some ` key ` should be called ` thingByKey ` .
5361 ``` javascript
5462 // Bad.
@@ -89,11 +97,6 @@ foreign name should be prefixed for disambiguation, or even both.
8997 const stopSequenceAsInt = parseInt (stopSequenceAsString);
9098 ```
9199
92- As soon as you start to have different representations of the same thing in the same function,
93- disambiguation on the content should be done. For example:
94- - ` timestampAsMoment ` vs ` timestampAsString `
95- - ` stopSequenceAsString ` vs ` stopSequenceAsInt `
96-
97100With some reasonable limits, one shouldn't be afraid to have long variable name, and be more afraid
98101 of meaningless names. For example:
99102- ` apiStopByStopIdByTripHeadsignByRouteId ` should be still preferred as ` dict ` or ` apiStops ` .
You can’t perform that action at this time.
0 commit comments