Documentation
Table of Contents
Writing Codes in BotanJs
Scoping
It is recommended to enclosed each class with (function(){ / CODES / })(); ( but NOT A MUST ) to ensure your variables and function would not collide with other predefined variables or other classes.
However, you can achive a higher compression ratio without enclosing. It is your choice to ensure the variable names would not collide each other ( such as adding prefixes ).
Namespaces
The Namespace MUST be defined for each beginning of the class via the predefined function __namespace. This tells the compiler to associate this file to the defined namespace.
Example
// Path/To/The/Namespace/MyExportedClassName.js (function() { var ns = __namespace( "Path.To.The.Namespace" ); // JSDoc is needed to prevent the closure compiler // compressing exported methods and properties /** @type {Path.To.Some.Other.Class} */ var OtherClass = __import( "Path.To.Some.Other.Class" ); // Enclosing also enables the private static scope var MyPrivateStaticVar = "Private static variable"; var MyClass = function() { }; MyClass.prototype.MyFunction = function() { }; // This will export your class to Path.To.The.Namespace.MyExportedClassName ns[ NS_EXPORT ]( EX_CLASS, "MyExportedClassName", MyClass ); })();