Single entry point FTW!
Many programming languages and environments require a Main Class, Main function or Main file as an entry-point to the program, it’s where the execution starts and also usually where you have access to command arguments. JavaScript on the browser isn’t one of those environments tho, and I think it is one of the reasons why many applications become a real maintenance nightmare. I believe that the “Main File/Function/Class” approach can help a lot to increase extensibility/maintainability and favor a good structure even for languages that doesn’t require this practice.
Many back-end frameworks started to adopt this technique over the past years, most of them have some sort of URL redirect that points to a “index” file or a router that decides which actions should be executed and which files should be loaded instead of having a single file for each page or section. This kind of abstraction increases flexibility a lot since you can just keep adding new pages/sections/features without having to care about the code structure, it also reduce code duplication since you don’t need to create a new file for each new page…
Flash projects have a Main Class which is the entry-point for the application and also works as the root node where all the child elements are attached (similar to the body element of an HTML file) and it helps you keep the code flow organized since you are sure that your Main Class constructor is executed before any other code, programs get easier to understand since it follows a logic order.
Read more…