TipsIn order to write future-proof code, it is recommended not to place many variables, functions or classes in the global namespace. This will prevent naming conflicts with third-party code as well as possible future additions to the language. One common way to prevent naming conflicts of functions and classes is to add them to their own dedicated namespace. Keeping track of the namespaces already in use is still necessary, but once a namespace has been chosen, all functions and classes can be added to it without having to think about conflicts again. It is considered best practice to limit the number of variables added to the global scope in order to prevent naming conflicts with third-party code.
|