Variable naming convention #307
Replies: 2 comments
-
I personally use
But such cases are rare, as you can usually omit the prefix and say "accesses the For code examples, I prefer the name that looks less like it was chosen on purpose. However, in general my experience is that strict naming conventions are really hard to enforce. We can at best tell people to prefer X over Y, but it's very likely that Y still keeps creeping into the content over time. |
Beta Was this translation helpful? Give feedback.
-
I agree with you |
Beta Was this translation helpful? Give feedback.
-
Java Script code style guide provides hints about variable naming, that I believe are too broad. There are plenty of pages in which different names are used for the same structures. On page Array.reduce different examples use names
array1
,array
andmyArray
for an ordinary array. In all JS content examples, the namearr
is used 75 times,myArray
23 times,array
22 times, while most of the interactive examples use the namearray1
. Map object is usually calledmyMap
,map
, ormap1
.I think the style guide should provide a list of fallback names, for each primitive value and data structure. Those names should be used, only when more expressive names like
cars
ornumbers
are not suitable. This convention should be also used for interactive examples, which have a separate style guide.Beta Was this translation helpful? Give feedback.
All reactions