First, let me clarify that the non-documentation approach doesn't mean avoiding documentation entirely. Rather, it relies on using forms of documentation other than explicit code comments.
For instance, consider the following line of code:
var Book = Backbone.Model.extend();
Now, if we had wanted to, we could have written a comment describing this line of code, as follows:
/** * This defines a book model. */Book = Backbone.Model.extend();
However, adding such a comment doesn't really tell us anything we don't already know, because our choice of variable name (Book
) already tells us what the class is. Simply by choosing a descriptive variable name for our class, we have documented what it does, without the need of supplemental documentation.
However, the names of class variables aren't the only important names. Function names, and particularly, method names, can also be very helpful in explaining what the function/method does. Consider the following:
bookNav...