Javascript Namespace Conventions
This is novel way we have found very very helpful in building out sophisticated user interfaces written with Javascript. Rather than following the industry standard of hiding Javascript functions within private names spaces implemented with closures - we use this approach.
Our convention is to make all our Javascript functions global and to use 2-5 capital letter prefixes so that we don’t run into problems with the same function name being used in two places. Then use the same prefix in the name of each Javascript file and arrange these files in a flat structure of directories named with each prefix.
i.e. COR/CORmain.js would have functions named function CORxxxxxx etc.
This is quite different to most of the public domain Javascript library conventions which are out there which tend to show wrapping functions up inside closures. The advantage our approach has is that:
By making functions global it means we can just call them directly inside the Javascript console. This makes for a much faster development and testing process since it aligns how we like to develop all our code.
This is much better than traditional slow approaches of opening up the debugger, stepping through the code etc. etc.
It makes it easy to break the code down into small files to meet separation of concerns.
It means we can eliminate boiler plate code by re-usable helper functions.
It is super easy to navigate the code base since the name of each function can be searched for globally and the directory convention makes it obvious where to look for it.
It’s a much much more effective way of building out rich functionality versus the conventional approach of wrapping everything in closures.