You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+27-2Lines changed: 27 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ Our styles are based on the excellent [javascript guide from Airbnb](https://git
11
11
## Exceptions
12
12
13
13
### Whitespace
14
-
- Limit your lines to 105 characters. eslint: [max-len](http://eslint.org/docs/rules/max-len).
14
+
- Limit your lines to 100 characters (with a 5 characters tolerance). eslint: [max-len](http://eslint.org/docs/rules/max-len).
15
15
> This ensures readability and maintainability.
16
16
17
17
```javascript
@@ -27,4 +27,29 @@ Our styles are based on the excellent [javascript guide from Airbnb](https://git
27
27
```
28
28
29
29
## Naming conventions
30
-
For sure, there are things we'd like to add here.
30
+
### Consistency and disambiguation
31
+
32
+
As soon as a concept as a name, this name should always be used to refer to that concept, and that name shouldn't be used to refer
33
+
to anything else.
34
+
35
+
Example:
36
+
- A `globalRouteId` is a unique identifier to a route. One should never call it `routeId` since it is another concept (used in the GTFS,
37
+
the tGTFS and the bgtfs with different meaning).
38
+
- A `feed` is an instance of the `transit_production.feeds` table. An `alertFeed` is an instance of the `service_update.alert_feeds` table.
39
+
40
+
41
+
If some external tools/library/api uses the same name for another concept, then at least the foreign name should be prefixed for disambiguation, or even both.
42
+
- When we match the stops from the GTFS to the stop from some real-time API, we call the first one `gtfsStop` and the second one `apiStop` even if the first one is usually just called stop.
43
+
44
+
45
+
### The name should describe the content
46
+
As much as possible:
47
+
- an array of `value` should be called just `values`;
48
+
- an object of `value` index by some `key` should be called `valueByKey`.
49
+
50
+
As soon as you start to have different representations of the same thing in the same function, disambiguation on the content should be done. For example:
51
+
-`timestampAsMoment` vs `timestampAsString`
52
+
-`stopSequenceAsString` vs `stopSequenceAsInt`
53
+
54
+
With some reasonable limits, one shouldn't be afraid to have long variable name, and be more afraid of meaningless names. For example:
55
+
-`apiStopByStopIdByTripHeadsignByRouteId` should be still prefered as `dict` or `apiStops`.
0 commit comments