In addition, each "word" within a class name should start
with an uppercase letter.
For example, TextMessage
and
SimpleTrafficMonitor
are both appropriate class names.
In addition, there should be an underscore between each "word".
For example, PAGE_LENGTH
.
Further, each "word" within a variable name should start
with an uppercase letter.
For example, importantMessage
and
campusMonitor
are both appropriate variable names.
In general, even single-character variable names should be lowercase. However, in some situations, mathematical notation uses uppercase letters. In such situations, uppercase variable names may be used. For example, matrices are often written using uppercase letters. So, an expression like (b = A*x) would be appropriate.
Variable names like aaa
are not appropriate.
Index variables and counters can, however, have names like
i
and j
.
var
.
Since ECMAScript/JavaScript does not have block scope, they should be declared at the top of the function/class.
In other words, even where semicolons are optional (i.e., implicit), semicolons must be included explicitly.
In other words, even where semicolons are optional (i.e., implicit), semicolons must be included explicitly.
The name of the file and the name of the class must coincide
exactly. For example the Queue
class should be
in a file named Queue.js
.
The name of the file must be descriptive.
This comment should describe the complete class/function library (rather than the methods in the class or functions in the library).
This comment should describe the methods, its parameters, and its return value.
//
rather than /* ... */
.
This isn't a requirement but it will make your life easier since you
can't nest comments inside of /* ... */
. There is
nothing more annoying then trying to "comment out" a section of code
while you are debugging and being unable to because it contains
block comments.
* * @author David Bernstein *
* * This work complies with the JMU Honor Code. *
if (...) { // ... } else { // ... }
This will avoid problems with implicit semicolon insertion.
Copyright 2019