I'm in the process of structuring my first backbone.marionette app and there are some things I find confusing.
In the backbone.marionette version of TodoMVC there seem to be two different modules performing the work of the App:
First there is TodoMVC which is an instance of Backbone.Marionette.Application and then there is TodoMVC.TodoList which seems to be nothing more than a container for holding the controller and router.
Why isn't the controller object simply added to the App object?
Another thing that confuses me: In other marionette apps I've seen discussed on stackoverflow, such as this one, addInitializer() is called on the app object but in the TodoMVC application addInitializer() is called on the todolist object.
Is this specific to apps that want to have a controller object?
I also find the naming rather confusing, since both the TodoMVC (app) and Todolist (controller container?) hold names that imply they are the base app. Could the Todolist module be more semantically called TodoController?
Why isn't the controller object simply added to the App object?
It's a modular design choice, related to the Single Responsibility Principle. TodoMVC is the top-level application and TodoList is a module (or sub-application) within our application, and they both tend to their own gardens. This allows us to make an arbitrary amount of modules without growing our top-level app code.
In other marionette apps... addInitializer() is called on the app object but in the TodoMVC application addInitializer() is called on the todolist object
I think this is just a matter of convention for Application.Modules. The TodoMVC app doesn't need any init code, so we don't add an init function.