View Full Version : Are Ext class members that are marked @private really private?

4 Jan 2013, 4:41 PM
I'm trying to determine the nature of class members that are marked @private and @protected. They don't seem to be defined differently than the "public" members, don't seem to fit into Crockford's definitions (http://javascript.crockford.com/private.html) and are visible in a debugger. I'm guessing that the @private and @protected annotations are just used for documentation filtering purposes (i.e. to hide/show those thus marked) and that for all practical purposes they are the same as "public" members.

Can anyone confirm or refute my assumptions?


Phil Guerrant
4 Jan 2013, 6:36 PM
Since JavaScript does not provide any access level control of an objects members, in Ext JS we put all class members on the class' prototype and use the @private and @protected tags to indicate the intended use of a class' members. As you've correctly observed, there's no way to enforce these access levels, so we document them to make sure users understand their intended use. I would not say that they are the "same" as public members though. The difference is, you can expect the public API to be stable between releases, however, private members are subject to change if the dev team deems it necessary.

Additionally, we sometimes use the @private tag internally to mean "For internal framework use only". If you browse the source code you may notice that some members are flagged as "private" but are used from classes other than the one in which they were defined. The actual usage of @private members in the framework may not be truly "private" in the classical OOP sense of the word, but we flag them as @private so that users know they are not part of the public API and should not be depended on.

4 Jan 2013, 6:39 PM
Very good answer.

Thank you.