Why doesn't the Google closure library use real private users?

I've been a JavaScript developer for a long time, and I always thought that the right way to implement private members in JavaScript is to use the technique described by Doug Crockford here: http://javascript.crockford.com/private.html .

I did not think this was a particularly controversial piece of JavaScript wisdom until I started using the Google Closure library. Imagine my surprise ... the library makes no effort to hide Crockford-style information. All they do is use a special naming convention and note the "private" members in the documentation. I have a habit of assuming that the guys from Google are usually at the forefront of software quality, and what gives? Is there a flaw in Mr. Crockford's next tip that is not obvious?

+5
source share
3 answers

There are many examples of pseudo-privacy in mainstream JavaScript libraries. Facebook Connect JavaScript library has the same structure.

, , - . . , . Closure-hiding , IMO, , - - .

, Google Python, , - .

+8

goog.inherit() goog.base() .

, . (this.property).

++ Java, , . , .

+1

In addition, to indicate JSDOC is also more than it seems at first glance - when you use the Google close compiler, those @private tags are parsed and executed. If any external objects try to access one of these variables, a compilation error is generated. They really have a philosophical objection to Crockford's general inheritance scheme: http://www.bolinfest.com/javascript/inheritance.php

0
source

All Articles